| | |
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
![]() |
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Use the "submit" method of the Form object. You should always give your form an ID:
Then, you can reference and submit the form with a script that looks like:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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)
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.
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.
![]() |
Similar Threads
- Save the values of a form (HTML and CSS)
- Fetching Form Values with ASP (ASP)
- Storing dynamic form values in Arrays for display & insert (PHP)
- How to pass the values of javascript in perl (JavaScript / DHTML / AJAX)
- Hyperlink POST using Javascript (JavaScript / DHTML / AJAX)
- Need help in design and javascript code for Dynamic form (JavaScript / DHTML / AJAX)
- Javascript, Form fields validation and submit (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: I need help with my website. Using Dreamweaver.
- Next Thread: Remove Selected Value from the Text Area
Views: 16390 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp animate api automatically beta box browser bug button calendar captchaformproblem card checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element engine events explorer ext file firehose flash form forms game google gwt gxt highlightedword html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump margin math matrixcaptcha microsoft mimic mp3 mysql object offline onmouseoutdivproblem onreadystatechange parent passing pdf php player post progressbar rated regex runtime scroll search session shopping size solutions sql star stars stretch synchronous text textarea twitter validation web website window windowofwords windowsxp wysiwyg xml xspf \n






