Multiple Checkboxes and multiple forms
Posted: Wed Dec 29, 2010 9:28 am
Hi all, am still struggling through the holidays trying t figure out how to solve this...
I have two pages, 'result.php' which generates a dynamic table, 'rfq.php' which is a form
when user click on the checkboxes in 'result.php and submit, it should pass the checkboxes values into the text fields in 'rfq.php'
if there are two checkboxes ticked, the two checkboxes values will fill up two of the text fields in 'rfq.php'
I need to pass two values from the row results 'MPN', "MFR' into the text fields 'partsnumber', 'manufacturer' respectively.
if there are two rows, then into 'partsnumber2', manufacturer2' etc.
the codes are as below:
Results.php
I'd tried to recreate a test page using the code below but can't get the results:
Would really appreciate if you guys could point out my mistakes and how i can improve on the codes.
Many thanks and happy holidays
I have two pages, 'result.php' which generates a dynamic table, 'rfq.php' which is a form
when user click on the checkboxes in 'result.php and submit, it should pass the checkboxes values into the text fields in 'rfq.php'
if there are two checkboxes ticked, the two checkboxes values will fill up two of the text fields in 'rfq.php'
I need to pass two values from the row results 'MPN', "MFR' into the text fields 'partsnumber', 'manufacturer' respectively.
if there are two rows, then into 'partsnumber2', manufacturer2' etc.
the codes are as below:
Results.php
Code: Select all
<form id="form1" name="form1" method="post" action="rfq.php">
<input name="hidSubmit" type="hidden" id="hidSubmit2" value="true">
<table width="100%" border="0" cellpadding="5" cellspacing="1">
<tr class="maintxt">
<th align="left" bgcolor="#CCCCCC">RFQ</th>
<?php if ($totalRows_rsPartsSearch > 0) { // Show if recordset not empty ?>
<th align="left" bgcolor="#CCCCCC">Parts Number</th>
<th align="left" bgcolor="#CCCCCC">Manufacturer</th>
<th align="right" bgcolor="#CCCCCC">Quantity</th>
<?php } // Show if recordset not empty ?>
</tr>
<?php do { ?>
<tr bgcolor="#C6ECFF" class="maintxt">
<td width="194" bgcolor="#bdc5c9"><input name="mpnrfq[]" type="checkbox" id="mpnrfq" value="<?php echo $row_rsPartsSearch['MPN']; ?>" /></td>
<td width="194" nowrap="nowrap" bgcolor="#bdc5c9"><?php echo $row_rsPartsSearch['MPN']; ?></td>
<td width="152" bgcolor="#bdc5c9"><?php echo $row_rsPartsSearch['MFR']; ?></td>
<td width="135" align="right" bgcolor="#bdc5c9"><?php echo $row_rsPartsSearch['TOTAL']; ?></td>
</tr>
<?php } while ($row_rsPartsSearch = mysql_fetch_assoc($rsPartsSearch)); ?>
</table>
<input type="submit" name="submitRFQ" id="submitRFQ" value="Submit" />
</form>
[u]Rfq.php[/u]
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="24%"><span class="maintxt">Parts Number</span></td>
<td width="18%"><span class="maintxt">Manufacturer</span></td>
<td width="11%"><span class="maintxt">Quantity</span></td>
<td width="16%" class="maintxt">Target Price</td>
<td width="31%" class="maintxt">Required Delivery Date</td>
</tr>
<tr>
<td><span id="sprypartnumber">
<input name="partsnumber" type="text" id="partsnumber" size="20" />
<span class="textfieldRequiredMsg">Required.</span></span></td>
<td><span id="sprymanufacturer">
<input name="manufacturer" type="text" id="manufacturer" size="15" />
<span class="textfieldRequiredMsg">Required.</span></span></td>
<td><span id="spryquantity">
<input name="quantity" type="text" id="quantity" size="6" />
<span class="textfieldRequiredMsg"> Required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
<td><input name="targetprice" type="text" id="targetprice" size="6" /></td>
<td><input name="deliverydate" type="text" id="deliverydate" size="10" /></td>
</tr>
<tr>
<td><input name="partsnumber2" type="text" id="partsnumber2" size="20" /></td>
<td><input name="manufacturer2" type="text" id="manufacturer2" size="15" /></td>
<td><input name="quantity2" type="text" id="quantity2" size="6" /></td>
<td><input name="targetprice2" type="text" id="targetprice2" size="6" /></td>
<td><input name="deliverydate2" type="text" id="deliverydate2" size="10" /></td>
</tr>
<tr>
<td><input name="partsnumber3" type="text" id="partsnumber3" size="20" /></td>
<td><input name="manufacturer3" type="text" id="manufacturer3" size="15" /></td>
<td><input name="quantity3" type="text" id="quantity3" size="6" /></td>
<td><input name="targetprice3" type="text" id="targetprice3" size="6" /></td>
<td><input name="deliverydate3" type="text" id="deliverydate3" size="10" /></td>
</tr>
</table>
Code: Select all
<form id="form1" name="form1" method="post" action="">
<p>
<?php
$strPartsID=$_REQUEST['mpnrfq'];
if(isset($hidSubmit)){
$count=count($mpnrfq);
for($i=0;$i<$count;$i++){$strPartsID="$strPartsID$mpnrfq[$i], ";}
}
?>
<?php
foreach ($strPartsID as $data)
?>
// <?php
// $partsid = $_REQUEST['mpnrfq[]'];
// ?>
<input name="partsid" type="text" id="partsid" value="<?php print $data; ?>" />
</p>
<p>
<input name="partsid2" type="text" id="partsid2" value="<?php echo $strPartsID[$i++]; ?>" />
</p>
</form>Many thanks and happy holidays
