0

How can i write this dynamically to use on a number of forms?

function submitform()
{
    if(document.hotelfrm.onsubmit &&
    !document.hotelfrm.onsubmit())
    {
        return;
    }
 document.hotelfrm.submit();
}

form name="hotelfrm" id="hotelfrm" method="post" action="page1.asp"

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.