I have an form page (see attached image con_pg1_form.png). In the form when the quantity (qty) is added the Amount field is auto computed.
below is code for the form page:
Code: Select all
<?php
$i = 1;
$j = 0;
$totalRec=0;
$total = 0.00;
//session_start();
$_SESSION['partnerIDs']="";
while($getProj = mysql_fetch_array($queryProjects)){
$partnerID = $getProj['PartnerIDs'];
$projName = $getProj['ProjectTitle'];
$projDesc = substr($getProj['ProjectStory'], 0, 80);
$projPicURL = $getProj['ProjectPicURL'];
$bizRef = $getProj['BusinessProductCustRef'];
$bizProName = $getProj['BusinessProductName'];
$unitValue = $getProj['ContributionUnitAmt'];
$conType = $getProj['ContributionType'];
$total = $total + $subtotal;
//echo "<td class='tblTD tblBT tblBL' align='center' width=142 height=100><img src='".$projPicURL."' /></td>";
echo "<td colspan='2' class='tblTD tblBT tblBL' valign='top'><strong>".$projName."</strong><br />";
echo $projDesc."... </td>";
echo "<td class='tblTD tblBT tblBL' valign='top' align='center'>".$bizProName."</td>";
echo "<td class='tblTD tblBT tblBL' valign='top' align='center'><input name='ref".$i."' class='YellowTextBoxMid'
maxlength=\"7\" type='text' value='".$bizRef."'/>";
if($conType=="R"){
$j = $j +1;
echo "<td class='tblTD tblBT tblBL' valign=\"top\" align=\"center\"><input class='YellowTextBoxMidTwo' maxlength=\"11\" name='startDate".$j."' id='startDate".$j."' type=\"text\" value=\"\" />";
echo "<td class='tblTD tblBT tblBL' valign=\"top\" align=\"center\"><input class='YellowTextBoxMidTwo' maxlength=\"11\" name='endDate".$j."' id='endDate".$j."' type=\"text\" value=\"\" />";
}
else if($conType=="C"){
$j = $j +1;
echo "<td class='tblTD tblBT tblBL' valign=\"top\" align=\"center\"><input name='startDate".$j."' id='startDate".$j."' type=\"hidden\" value=\"\" />";
echo "<td class='tblTD tblBT tblBL' valign=\"top\" align=\"center\"><input name='endDate".$j."' id='endDate".$j."' type=\"hidden\" value=\"\" />";
}
echo "<td class='tblTD tblBT tblBL' valign='top' align='center'>".$unitValue."</td>";
echo "<td class='tblTD tblBT tblBL' valign=\"top\" align=\"center\"><input class='YellowTextBoxNarrowTwo'
maxlength=\"7\" size=\"7\" name=\"qty".$i."\"
id=\"qty".$i."\" type=\"text\" value=\"\" onchange=\"readQty('qty".$i."','subtotal".$i."','unitPrice".$i."','".$i."','".$conType."')\"/>";
echo "<td class='tblTD tblBT tblBL tblBR' valign='top' align='center'><input maxlength=\"7\" size=\"7\"
name='subtotal".$i."' id='subtotal".$i."' type='text' style='text-align:center;'
value='".$subtotal."' disabled /></td></tr>";
echo "<input type='hidden' name='unitPrice".$i."' id='unitPrice".$i."' value='".$unitValue."' />";
echo "<input type='hidden' name='conType".$i."' value='".$conType."' />";
echo "<input type='hidden' name='projName".$i."' value='".$projName."' />";
echo "<input type='hidden' name='sub".$i."' id='sub".$i."' value='".$subtotal."' />";
echo "<input type='hidden' name='grandTotal' value='".number_format($total,2)."' />";
$_SESSION['partnerIDs'] = $_SESSION['partnerIDs'] . " ".$partnerID;
$_SESSION['totalRecords'] = $i;
$_SESSION['regular'] = $j;
$i = $i +1;
}// while loop
$i = $i - 1;
$totalRec = $i;
$_SESSION['partnerIDs'] = ltrim($_SESSION['partnerIDs']);
?>
<tr>
Experts can show me why it doesn't work...
below is the code for the action page:
Code: Select all
<?php
session_start();
$totalRecord = $_SESSION['total'];
$i =$totalRecord;
echo 'grandTotal '.$_POST['grandTotal'].'<br>';
echo 'subtotal '.$_POST['subtotal4'].'<br>';
echo 'sub4 '.$_POST['sub4'].'<br>';
for($i=1; $i<=$totalRecord; $i++){
echo "<tr>";
echo "<td align='center' class='tblTD tblBT tblBL'>";
echo $_POST['projName'.$i];
echo "</td>";
echo "<td align='center' class='tblTD tblBT tblBL'>";
echo $_POST['ref'.$i];
echo "</td>";
echo "<td align='center' class='tblTD tblBT tblBL'>";
echo $_POST['unitPrice'.$i];
echo "</td>";
echo "<td align='center' class='tblTD tblBT tblBL'>";
echo $_POST['qty'.$i];
echo "</td>";
echo "<td align='center' class='tblTD tblBT tblBL tblBR'><b>";
echo $_POST['sub'.$i];
echo $_POST['unitPrice'.$i];
echo "</b></td>";
echo "</tr>";
}
echo "<tr>";
echo "<td align='right' class='tblTH tblHB tblTHBB' colspan='4'><b>Total USD</b></td>";
echo "<td align='center' class='tblTD tblBT tblBL tblBR tblTHBB'><b>";
echo $_POST['grandTotal'];
echo "</b></td></tr>";
?>
Code: Select all
echo 'grandTotal '.$_POST['grandTotal'].'<br>';
echo 'subtotal '.$_POST['subtotal4'].'<br>';
echo 'sub4 '.$_POST['sub4'].'<br>';grandTotal 0.00
subtotal
sub4
Thanks Experts