|
Q196 How can I have two submit buttons with different actions in one form?
irt.org | Knowledge Base | JavaScript | Form 7.2 | Q196 [ previous next ]
Q196 How can I have two submit buttons with different actions in one form?
With Microsoft Internet Explorer 3 it is not possible to update the
forms ACTION attribute as it is read only. Therefore the following
has to be used when the solution must work across all browsers:
<html>
<head>
<script language="JavaScript"><!--
function copydata() {
document.two.text1.value = document.one.text1.value;
document.two.text2.value = document.one.text2.value;
}
//--></script>
</head>
<body>
<form name="one" action="apage.html" method="post">
<input type="text" name="text1">
<input type="text" name="text2">
<input type="submit">
</form>
<form name="two" action="bpage.html" method="post">
<input type="hidden" name="text1">
<input type="hidden" name="text2">
<input type="submit" onClick="copydata()">
</form>
</body>
</html>
|
If however, you are not worried about older browsers, then you can try
the following suggested by Bill Wilkinson:
<form name="theform" action="oops.htm" method="get">
<input name="one" value="type something here...">
<input type="submit" name="submit" value="first" onClick="document.theform.action='first.htm';">
<input type="submit" name="submit" value="second" onClick="document.theform.action='second.htm';">
</form>
|
Feedback on 'Q196 How can I have two submit buttons with different actions in one form?'
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.