Dynamic script for submitting a form
How can i write this dynamically to use on a number of forms?
function submitform()
{
if(document.hotelfrm.onsubmit &&
!docume开发者_StackOverflow社区nt.hotelfrm.onsubmit())
{
return;
}
document.hotelfrm.submit();
}
form name="hotelfrm" id="hotelfrm" method="post" action="page1.asp"
Have a look at document.forms.
You might want to tryout something like this:
function submitforms() {
for(var i = 0; i < document.forms.length; i++) {
if(document.forms[i].onsubmit && !document.forms[i].obsubmit()) {
return;
}
document.forms[i].submit();
}
}
Please note I didn't check your code validity and reasonableness.
精彩评论