开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜