I am trying to multiply the price with quantity and insert it into amount text field without doing a post. Is there a way if I enter quantity the amount would show?
$rs = mysql_query("SELECT * FROM contributions where type = 'ticket'");
// create an array holding the classes you want to switch between
$classes=array("td1","td2");
// a counter to keep track of which class is currently being used
$classifier=0;
$num = mysql_num_rows($rs);
$i = 0;
echo "<TABLE width=100% align=left cellpadding=5 cellspacing=0>";
echo "<tr class=trhead >";
echo"<td>Description</td>";
echo"<td>Price</td>";
echo"<td>Quantity</td>";
echo"<td>Amount</td>";
echo "</tr>";
while ($i < $num){
$description = mysql_result($rs,$i,"description");
$price= mysql_result($rs,$i,"price");
//$dmiddle= mysql_result($rs,$i,"middle");
// access the value in the array associated with the key equal to the counter and print it in the <tr> bg
echo "<tr class=" . $classes[$classifier] .">";
echo "<td>" . $description . "</td>";
echo "<td>" ."$". $price . "</td>";
echo '<td><input type="text" name="quantity[]" value="" size="1" /></td>';
$myamount = $price * $_GET[quantity];
echo '<td ><input type="text" name="amount[]" value="" size="3" /></td>';
$i++;
// increment the counter and mod it by 2 to effectively alternate between two numbers
$classifier=($classifier+1)%2;
}
}
echo "</table>";
?>