Ajax auto submit form without buttons?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Jun 2009
Posts: 8
Reputation: eshko is an unknown quantity at this point 
Solved Threads: 0
eshko eshko is offline Offline
Newbie Poster

Ajax auto submit form without buttons?

 
0
  #1
Jun 12th, 2009
Hi everyone,
I have one-field form on my website, which is supposed to be filled with barcode number. It was functional until few days age when the need emerged for the auto-submit.
As you can see, I have to make script which will automatically submit form when data is filled in barcode field.
Does anyone can give me some short guides how to do that, or just give me a link to some good tutorial or something?
Thanks...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Ajax auto submit form without buttons?

 
0
  #2
Jun 12th, 2009
You can submit your form by stating it inside your conditional statement.
e.g
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. if ( true ) {
  2. document.formId.submit(); return true; }
  3. return false;
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

Re: Ajax auto submit form without buttons?

 
0
  #3
Jun 12th, 2009
Eshko,

Do you really mean AJAX?

Form submission is a feature of bog-standard HTML/HTTP and can be triggered either by the user clicking the form's submit button or from javascript, eg, forms[0].submit() , which is safe as long as you have just one form on the page. This approach will send a standard HTTP request and will cause the page to be refreshed or renewed depending on the form's action .

Yes, you can cause form data to be submitted via an "AJAX request" but you only do this when you need to submit the data without refreshing/renewing the page. I don't have time to get into a lengthy description of the javascript involved, but it is well very documented on the web.

In itself, "auto submit" infers the first type of request, which is why I question "AJAX". It is not uncommon for folks to think they are using AJAX when they are not (with sincere appologies if this doesn't apply to you).

Maybe you could advise as to which type of HTTP request you are using and also post some code (HTML & JS) so we can see what might be wrong.

Airshow
Last edited by Airshow; Jun 12th, 2009 at 9:02 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: eshko is an unknown quantity at this point 
Solved Threads: 0
eshko eshko is offline Offline
Newbie Poster

Re: Ajax auto submit form without buttons?

 
0
  #4
Jun 12th, 2009
I don't get the point. I don't have any conditional statments. Markup looks like this:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <form method="post" action="action.php">
  2. <input type="text" name="barcode" /><br />
  3. <input type="submit" value="Add" />
  4. </form>

I need to remove that submit button, and make it work on way I described in first post.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: eshko is an unknown quantity at this point 
Solved Threads: 0
eshko eshko is offline Offline
Newbie Poster

Re: Ajax auto submit form without buttons?

 
0
  #5
Jun 12th, 2009
Ok, maybe I didn't described my problem well.
I'll try again.

I have site with mysql backend where I store informations about products. One part of site is one-field form, where the customer inserts the barcode of his product, and that form sends data to php script which is processing bla bla bla, and shows the result of that process...

Now, for costumer it will be simpler to do:
Costumer insert data in barcode field in main form and script automatically submits data to action.php which is processing it and shows the result on the same page as that main form.

*Costumers insert data with barcode reader, so process is very quickly.
*action.php already works, and it shows results in table.

thanks again
Last edited by eshko; Jun 12th, 2009 at 9:16 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

Re: Ajax auto submit form without buttons?

 
0
  #6
Jun 12th, 2009
Eshko,

OK, that sounds like genuine AJAX.

Would I be correct in understanding that you need to trigger an existing ajax script in response to a user event other than button click? If so it's trivial but I must fly now. I'm running late. Maybe Essential will come back ( he's very reliable ). If not I'll be here again in a few hours.

Airshow
Last edited by Airshow; Jun 12th, 2009 at 9:25 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

Re: Ajax auto submit form without buttons?

 
0
  #7
Jun 12th, 2009
And with any luck my Daniweb email alerts will be arriving today .....
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: eshko is an unknown quantity at this point 
Solved Threads: 0
eshko eshko is offline Offline
Newbie Poster

Re: Ajax auto submit form without buttons?

 
0
  #8
Jun 12th, 2009
Airshow,
thank you very much for helping me...

I solved one part of problem deciding that results from action.php won't be loaded in same page where main form is located. So the only problem I don't know how to figure out is how to make auto submit.

I don't have any ajax script on site yet.

I was looking on web for something that looks like what I need, and i found this: http://metak.com/

So, as you can see, this website have that auto-submitting system which I need for my website.

So, any ideas how to make it?

Thanks again
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Ajax auto submit form without buttons?

 
0
  #9
Jun 12th, 2009
Hi guys,

i think i'm hanging my head around here, reading all your post. And i must admit, Airshow, is more reliable than me and always have his effective, efficient and precise solution...

But i think Airshow is on the run right now, rushing his way to work...

If you need some help with the AJAX script, just let me know and i'll create one for you...
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: eshko is an unknown quantity at this point 
Solved Threads: 0
eshko eshko is offline Offline
Newbie Poster

Re: Ajax auto submit form without buttons?

 
0
  #10
Jun 12th, 2009
Hey,
first of all i want to thank you all for helping me.

essential,
as you can see in my posts, i need script for auto-submitting the form.
This is my markup:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <form action="action.php" method="post">
  2. <input type="text" name="barcode" /> <input type="submit" value="Add" />
  3. </form>

I want to make an auto-submitting script which will automaticaly submit this form when user inserts data in barcode field, without clickink on submit button... I don't have idea how to make this...

thanks...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC