Hi,
I have a form I would like to submit using a javascript function, in order to change some hidden field before to go to next step (it's a multi page form).
I have put the following buttons in my form
<input name="submit" value="next option A" type="button" onclick="javascript:choseOttima(false);"><input name="submit" value="next option b" type="button" " onclick="javascript:choseOttima(true);">
and made the following in javascript code
function choseOttima(valore){
if (valore == true) {document.getElementById('ottima').value='1';}else{document.getElementById('ottima').value='0';}
document.myformname.submit();
}
My problem is that javascript return the following error:
Error: document.myformname.submit is not a function
What I'm doing wrong?
Thank yo for your help
Luca
I have a form I would like to submit using a javascript function, in order to change some hidden field before to go to next step (it's a multi page form).
I have put the following buttons in my form
<input name="submit" value="next option A" type="button" onclick="javascript:choseOttima(false);"><input name="submit" value="next option b" type="button" " onclick="javascript:choseOttima(true);">
and made the following in javascript code
function choseOttima(valore){
if (valore == true) {document.getElementById('ottima').value='1';}else{document.getElementById('ottima').value='0';}
document.myformname.submit();
}
My problem is that javascript return the following error:
Error: document.myformname.submit is not a function
What I'm doing wrong?
Thank yo for your help
Luca
I have fund the problem...
Having a function trying to call the form's submit() method do not work if the you also have a button which is called submit(). This causes a conflict in javascript, because the submit method is already bound to that button.
To solve the problem, simply change the name of the button so that name="bottone" (or something). Your submit() call in your javascript function/method will now work.
I have found a post on this problem on a different forum
Hope this can help others...
Luca
Having a function trying to call the form's submit() method do not work if the you also have a button which is called submit(). This causes a conflict in javascript, because the submit method is already bound to that button.
To solve the problem, simply change the name of the button so that name="bottone" (or something). Your submit() call in your javascript function/method will now work.
I have found a post on this problem on a different forum
Hope this can help others...
Luca
This topic is locked and no more replies can be posted.
