954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

Can any one explain me how to submit form value using JavaScript?

ksknagaprasad
Newbie Poster
1 post since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

Use the "submit" method of the Form object. You should always give your form an ID:

<form id="myForm" action="myServerSideCode.php" method="post"></form>


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

document.getElementById("myForm").submit();
tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

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.

alpha_foobar
Junior Poster
182 posts since May 2005
Reputation Points: 20
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You