You are here: irt.org | FAQ | JavaScript | Form | 7.2 | Q196 [ previous next ]
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>