Is it possible to submit form values using JavaScript? How?

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

Join Date: Dec 2005
Posts: 1
Reputation: ksknagaprasad is an unknown quantity at this point 
Solved Threads: 0
ksknagaprasad ksknagaprasad is offline Offline
Newbie Poster

Is it possible to submit form values using JavaScript? How?

 
0
  #1
Dec 23rd, 2005
Can any one explain me how to submit form value using JavaScript?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Is it possible to submit form values using JavaScript? How?

 
0
  #2
Dec 23rd, 2005
Use the "submit" method of the Form object. You should always give your form an ID:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <form id="myForm" action="myServerSideCode.php" method="post"></form>

Then, you can reference and submit the form with a script that looks like:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.getElementById("myForm").submit();
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Is it possible to submit form values using JavaScript? How?

 
0
  #3
Jan 4th, 2006
It is possible to do much more than this. You can build your entire http send or post response, with message and header fields. And you can do it reasonably quickly using html DOM traversal by element type (which you can call on any html element or the html body element) and you can process the content of the elements using browser methods to make them URI compatible.

However you will need to build server side functionality to translate this. Alternatively you can build a client-side translator in JavaScript, but this is only efficient with small form elements (with content less than 250 characters).

This approach is very useful if you have a specific reason for it, but it is much more complicated than the technique described by Thomas.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 16390 | Replies: 2
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