|
Posted by Richard Levasseur on 03/31/06 06:26
Two ways:
You can change the form action using javascript (easy and clean,
really), or
You can read the submit buttons value and proceed accordingly.
The first sounds more like what you want.
Case 1:
<form>
<input fields>
<input type="submit" name="submit" value="goto page 1"
onClick="form.action='page1.php';"/>
<input type="submit" name="submit" value="goto page 2"
onClick="form.action='page2.php';"/>
</form>
The javascript in the onClick handler of the submit buttons inherits
'form' from the current form they are in, avoiding the use of having to
do getElementByID() or document.formname.action=blalba.
Case2:
<form action="mypage.php">
<input fields>
<input type="submit" name="submit" value="goto page 1"/>
<input type="submit" name="submit" value="goto page 2"/>
</form>
mypage.php :
<? if($submit == 'goto page 1') { process according to page 1's method
} else { process according to page 2's method } ?>
Obviously this wouldn't work unless the code for both pages could be
consolidated into that single page, in which case you would be better
off using case 1.
Navigation:
[Reply to this message]
|