|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Need help with this JS form submitter
I cannot get the following code to work. I have tried various .submit() varieties - but they all give an error stating that xxx.submit is not a function - and the form is not submitted.
<head> <script language=JavaScript> function doB(x) { var a = document.getElementById("submitForm"); a.value = x; document.forms[0].submit(); // document.bForm.submit(); // var f = document.getElementById("bForm"); // f.submit(); } </script> </head> <body> <form name="bForm" id="bForm" action="default.asp" method="post"> <input id="submitForm" type="hidden" name="submit" value=""> <div onClick="doB('Option 1);">Option 1</div> <div onClick="doB('Option 2');">Option 2</div> </form> </body> </html> Any help will be appreciated |
|
#2
|
|||
|
|||
|
The document.bForm.submit(); should work, be sure that you have javascript enabled on your browser. And be sure to try it out in different browsers to see if any work. I do see one problem though... on this line:
<div onClick="doB('Option 1);">Option 1</div> you are missing a second quote on doB('Option 1'); |
|
#3
|
|||
|
|||
|
Thanx for the reply.
I eventually found the answer the name=submit in the <input> tag was causing the problem - I changed it to submitX and it worked. The missing quote was a typo. Thanx very much Regards J |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Need help with this JS form submitter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|