Jump to content

[SOLVED] Multiple forms with one submit button without using Javascript


Mr_jmm

Recommended Posts

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'); // 
?>

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.

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'] ?>"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.