Submitting a Form


document.forms[0].submit(); 

Usually, a submit button (<input type="submit" />) or a submit image (<input type="image" />) is used to send form data to the web server. However, JavaScript is capable of submitting a form as well, using the form's submit() method. This allows programmers to use an HTML link, for instance, to submit a form, providing more flexibility from a designer's point of view. However, do keep in mind that the following code works only when JavaScript is activated:

Submitting a Form (submit.html)

<form>   <input type="hidden" name="field" value="data" /> </form> <a href="javascript:document.forms[0].submit();"> Submit form</a> 




JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net