submit form data in multiple buttons on a html form

M

Matt

The problem is I have 3 buttons that need to submit the form to different
URL.
My approach is to declare <input type="submit"> rather than <input
type="button">.
And put the following in the JavaScript:
InputForm.action="URL LOCATION"
InputForm.method="POST";

I think we don't need InputForm.submit(); because <input type="submit">.

Please advise and comment my approaches. Thanks!!

==============================================
<html>
<head>
<script type="text/javascript">
function onClickURL1()
{ InputForm.action="url1.asp"
InputForm.method="POST";
//InputForm.submit(); //NOT NECESSARY!! because of input type="submit"??
}
function onClickURL2()
{ InputForm.action="url2.asp"
InputForm.method="POST";
//InputForm.submit(); //NOT NECESSARY!! because of input type="submit"??
}
function onClickURL3()
{ InputForm.action="url3.asp"
InputForm.method="POST";
//InputForm.submit(); //NOT NECESSARY!! because of input type="submit"??
}
</script>
</head>
<body>
<form name="InputForm">
<P><input type="text" name="username">
<P><INPUT type="submit" value="submit form data to URL1" name="action1"
onclick="onClickURL1()">
<P><INPUT type="submit" value="submit form data to URL2" name="action2"
onclick="onClickURL2()">
<P><INPUT type="submit" value="submit form data to URL3" name="action3"
onclick="onClickURL3()">
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top