how to submit form on clicking a link
Moderator: General Moderators
how to submit form on clicking a link
Hi,
Im stuck with one more problem,
How do I submit a form on clicking a link
where should I use javascript.form.submit in the before ahref or after ahref
Im stuck with one more problem,
How do I submit a form on clicking a link
where should I use javascript.form.submit in the before ahref or after ahref
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
Code: Select all
<a href="javascript: myform.submit()">Submit This Form</a>- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Code: Select all
<form name="myform">
<input type="text" name="somthing" value="this will submit">
</form>
<a href="javascript: myform.submit()">Submit The Form</a>-
Black Unicorn
- Forum Commoner
- Posts: 48
- Joined: Mon Jun 16, 2003 9:19 am
- Location: United Kingdom
Code: Select all
<form name="myform">
<input type="text" name="somthing" value="this will submit">
</form>
<a href="javascript:document.forms[0].submit()">Submit The Form</a>- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Make sure you do not have a submit button named "submit". This can cause problems. Always give the submit buttons meaningful names.
Multiple ways should work
or if you only have one form on the page,
where forms[0] is the first form, forms[1] is the second etc.
Placing in the <head> of the document means you do not have to specify javascript so you could shorten it to (useful if you only use javascript, not vbscript whatever.
:
Multiple ways should work
Code: Select all
onclick="javascript:document.myform.submit();"
onclick="javascript:document.forms['myform'].submit();"Code: Select all
onclick="javascript:document.forms[0].submit();"Placing
Code: Select all
<meta http-equiv="Content-Script-Type" content="text/javascript">Code: Select all
onclick="document.myform.submit();":