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

Recommended Answers

All 2 Replies

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();

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.