Occassionally it may be necessary to submit a form to multiple
CGIs based on a particular condition. With JavaScript, it is
possible to dynamically change the 'action' property of the form.
The example below demonstrates this.
NOTE: Please change the destination URL accordingly.
<html>
<head>
<h3>Submitting a single form to multiple CGIs</h3>
<script>
function submitToCGI1()
{
document.myForm.action =
"/old?u=http%3A%2F%2Fgraphite%2Fcgi-bin%2Fjunhe%2Fechotext%2F&y=1999"
document.myForm.submit();
}
function submitToCGI2()
{
document.myForm.action =
"/old?u=http%3A%2F%2Fgraphite%2Fcgi-bin%2Fjunhe%2Fechotext1%2F&y=1999"
document.myForm.submit();
}
</script>
</head>
<body>
<form name="myForm" METHOD=POST>
<input type=text name=text1>
<input type=text name=text2>
<input type=button value="Submit 1" onClick="submitToCGI1()">
<input type=button value="Submit 2" onClick="submitToCGI2()">
</form>
</body>
</html>
- Related Reading
Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use