abch624 Posted February 22, 2009 Share Posted February 22, 2009 Hi Guys, I have this piece of code"a form" that submits to the product.php when the submit button is clicked but I want the same input fields to be posted to a different script when a continue button is clicked!!! <form method="post" action="product.php"> <table width="200" cellpadding="2" cellspacing="0" border="0" > <tr> <td style="width:100;"> Frame </td> <td style="width:100; padding-bottom:10px;"> <select name="frame" id="frame"> <option>Volvo</option> <option>Saab</option> <option>Mercedes</option> <option>Audi</option> </select> </td> <tr> <tr> <td style="width:100;"> Size </td> <td style="width:100; padding-bottom:10px;"> <select name="size" id="size"> <option>Volvo</option> <option>Saab</option> <option>Mercedes</option> <option>Audi</option> </select> </td> <tr> <tr> <td style="width:100;"> </td> <td style="width:100; text-align:right;"> <input type="submit" value="Submit"> </td> </tr> </table> </form> Guys I need your help with how to submit the same form/fields to different scripts when different buttons are clicked! Thanks for helping - Zahid Quote Link to comment https://forums.phpfreaks.com/topic/146310-solved-form-submit/ Share on other sites More sharing options...
dropfaith Posted February 22, 2009 Share Posted February 22, 2009 you could use javascript to select it out <script lang="javascript"> <!-- function subit(which) { if (which == 1) { document.myform.action = 'somepage.php?who=1'; } else if (which == 2) { document.myform.action = 'somepage.php?who=2'; } document.myform.submit(); } //--> </script> <form method="post" name="myform"> Type Name:<br> <input type="text" name="username" value = ""> <input type="button" value="Your name" onClick="javascript:subit(1);"> <input type="button" value="Child's name" onClick="javascript:subit(2);"> </form> somepage.php <? if ($_GET['who'] == 1) { echo "who equals 1"; } else if ($_GET['who'] == 2) { echo "who equals 2"; } ?> <script lang="javascript"> <!-- function subit(which) { if (which == 1) { document.myform.action = 'somepage.php?who=1'; } else if (which == 2) { document.myform.action = 'somepage.php?who=2'; } document.myform.submit(); } //--> </script> <form method="post" name="myform"> Type Name:<br> <input type="text" name="username" value = ""> <input type="button" value="Your name" onClick="javascript:subit(1);"> <input type="button" value="Child's name" onClick="javascript:subit(2);"> </form> somepage.php <? if ($_GET['who'] == 1) { echo "who equals 1"; } else if ($_GET['who'] == 2) { echo "who equals 2"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/146310-solved-form-submit/#findComment-768124 Share on other sites More sharing options...
Cosizzle Posted February 22, 2009 Share Posted February 22, 2009 Use sessions to store your info and call the variables from the session Quote Link to comment https://forums.phpfreaks.com/topic/146310-solved-form-submit/#findComment-768129 Share on other sites More sharing options...
abch624 Posted February 22, 2009 Author Share Posted February 22, 2009 Nice One. New trick in my pot Quote Link to comment https://forums.phpfreaks.com/topic/146310-solved-form-submit/#findComment-768135 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.