firedrop84 Posted March 21, 2006 Share Posted March 21, 2006 I have another question. when I got for example in a form a submit button I usually use the action in the form and thats in the HTML to allow it to go for the page that I would like. I am wondering what if I have two buttons that they do two different actions. How I can handle this. Quote Link to comment Share on other sites More sharing options...
webwiese Posted March 21, 2006 Share Posted March 21, 2006 [!--quoteo(post=356884:date=Mar 21 2006, 08:44 AM:name=firedrop)--][div class=\'quotetop\']QUOTE(firedrop @ Mar 21 2006, 08:44 AM) [snapback]356884[/snapback][/div][div class=\'quotemain\'][!--quotec--]I have another question. when I got for example in a form a submit button I usually use the action in the form and thats in the HTML to allow it to go for the page that I would like. I am wondering what if I have two buttons that they do two different actions. How I can handle this.[/quote]Hi,don't use any action or use action = "<?echo $PHP_SELF?>" to call the same script. Then use an if ... elseif ... else - construct like[code]<?php# Submit - Button #1if (isset($_POST[submit_button_1]) { # action for submit - button #1} // if# Submit - Button #2elseif (isset($_POST[submit_button_2]) { # action for submit - button #2} // if# Standard - formelse { ?> <form method = "POST"> ....... </form> <?} // else?>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted March 21, 2006 Share Posted March 21, 2006 Give buttons the same name then check the value to get clicked button[code]<?phpif (isset($_POST['submit'])) { switch ($_POST['submit']) { case 'A': echo 'Button A was pressed<br>'; break; case 'B': echo 'Button B was pressed<br>'; break; }}?><FORM METHOD='POST'><INPUT TYPE='SUBMIT' name='submit' value='A'><INPUT TYPE='SUBMIT' name='submit' value='B'></FORM>[/code] Quote Link to comment Share on other sites More sharing options...
firedrop84 Posted March 21, 2006 Author Share Posted March 21, 2006 thanx for the script. It is working on my page now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.