Reply to Re: 1 Form, 2 Actions?

Your name:

Reply:


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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация