Click to See Complete Forum and Search --> : is it possible?


damon2003
11-04-2003, 04:49 AM
is it possible to have 2 images that act as submit buttons on a page that get submitted to 2 different pages? ie. button one wil send form variables to page 1 and button 2 will send form variables to page2
thanks

Gollum
11-04-2003, 05:12 AM
yes it is...

<img src="img1.gif" onclick="document.theForm.action='page1.asp'; document.theForm.submit();">
<img src="img2.gif" onclick="document.theForm.action='page2.asp'; document.theForm.submit();">

Charles
11-04-2003, 05:23 AM
Or, a bit more simply:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>

<form action="default.pl">
<div>
<input type="image" src="someSrc.png" onclick="this.form.action = 'another.pl'">
<input type="image" src="someOtherSrc.png" onclick="this.form.action = 'yetAnother.pl'">
</div>
</form>

Note, this has the added advantage that the page will still get submitted for the 13% of users who do not use JavaScript. Make sure that your default action sorts things out server side.