Mr_jmm Posted January 28, 2008 Share Posted January 28, 2008 Hi All, Without using any Javascript, is it possible to have multiple forms with only one submit button? What I have is a php script that loops through an array (from a query result) and foreach item displays a form with product information on it. The form has radio buttons for people to use to rate a product (later this will be images). I can't find a way to give each set of review buttons a unique id. Actually, to be exact, I can't work out how a query would work. <fieldset class="ratings2" id="<?php echo $row[$key]['basket_id']; ?>"> <legend class="legend"> <?php echo $row[$key]['basket_product_title'] .' (' .$row[$key]['basket_product_id'] .')'; ?> </legend> <br /><input type="text" name="basket_id" id="basket_id" value="<?php echo $row[$key]['basket_id']; ?>" /> <p><label id="q1">question1: </label><input type="radio" name="q1_button" id="q1_button" value="1" /><input type="radio" name="q1_button" id="q1_button" value="2" /><input type="radio" name="q1_button" id="q1_button" value="3" /><input type="radio" name="q1_button" id="q1_button" value="4" /><input type="radio" name="q1_button" id="q1_button" value="5" checked /></p> <p><label id="q2">question2: </label><input type="radio" name="q2_button" id="q2_button" value="1" /><input type="radio" name="q2_button" id="q2_button" value="2" /><input type="radio" name="q2_button" id="q2_button" value="3" /><input type="radio" name="q2_button" id="q2_button" value="4" /><input type="radio" name="q2_button" id="q2_button" value="5" checked /></p> <p><label id="q3">question3: </label><input type="radio" name="q3_button" id="q3_button" value="1" /><input type="radio" name="q3_button" id="q3_button" value="2" /><input type="radio" name="q3_button" id="q3_button" value="3" /><input type="radio" name="q3_button" id="q3_button" value="4" /><input type="radio" name="q3_button" id="q3_button" value="5" checked /></p> <p><label id="q4">question4: </label><input type="radio" name="q4_button" id="q4_button" value="1" /><input type="radio" name="q4_button" id="q4_button" value="2" /><input type="radio" name="q4_button" id="q4_button" value="3" /><input type="radio" name="q4_button" id="q4_button" value="4" /><input type="radio" name="q4_button" id="q4_button" value="5" checked /></p> <p><label id="q5">question5: </label><input type="radio" name="q5_button" id="q5_button" value="1" /><input type="radio" name="q5_button" id="q5_button" value="2" /><input type="radio" name="q5_button" id="q5_button" value="3" /><input type="radio" name="q5_button" id="q5_button" value="4" /><input type="radio" name="q5_button" id="q5_button" value="5" checked /></p> </fieldset> <?php $row = query_array('SELECT basket_id, basket_product_title, basket_product_id FROM basket b LEFT JOIN site_order s ON b.basket_session_id = s.order_session_id WHERE md5(VendorTxCode) = "' .substr($_SERVER[QUERY_STRING], 2, 32) .'"'); #$row = mysql_fetch_array($get_id_query); foreach ($row as $key => $foo) { include('./includes/ratings_sets.inc.php'); // ?> Quote Link to comment https://forums.phpfreaks.com/topic/88199-solved-multiple-forms-with-one-submit-button-without-using-javascript/ Share on other sites More sharing options...
GameYin Posted January 29, 2008 Share Posted January 29, 2008 It's quite simple, have them all assigned a name, have the action go to a processing page, and use the fields variable names depending on what you set then as, and do whatever you want. You can have infinite number of fields on a field. Quote Link to comment https://forums.phpfreaks.com/topic/88199-solved-multiple-forms-with-one-submit-button-without-using-javascript/#findComment-452162 Share on other sites More sharing options...
Mr_jmm Posted January 29, 2008 Author Share Posted January 29, 2008 Cheers. Solution was along the same line. One form with one submit button, have a form-handler included which each set of ratings sets all running identical queries each with a key from the array. I then extended the button's names to include some other intentifier. In this case the product code. Button name becomes: name="q1_button_<?php $row[$key]['product_id'] ?>" Quote Link to comment https://forums.phpfreaks.com/topic/88199-solved-multiple-forms-with-one-submit-button-without-using-javascript/#findComment-452851 Share on other sites More sharing options...
GameYin Posted January 30, 2008 Share Posted January 30, 2008 Good job figuring that out. Interesting way your figured out a solution. I wouldn't have done it that way but it works! Quote Link to comment https://forums.phpfreaks.com/topic/88199-solved-multiple-forms-with-one-submit-button-without-using-javascript/#findComment-453403 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.