javascript - Performing Functions on a Dynamically Created Table -


i retrieving 30 bakery items mysql database dynamic html table using php. data retrieved product, item (primary key), weight, , price. code creates input box, called quantity, each item user can type in how many cases wants. below segment of code used generate dynamic table:

        $i=0;      while ($i < $num) {         $item=mysql_result($result,$i,"item");         $product=mysql_result($result,$i,"product");         $weight=mysql_result($result,$i,"weight");         $bgprice=mysql_result($result,$i,"bgprice");      echo "<tr>";     echo "<td>$product</td>";     echo "<td><input name=item size=5 value=$item readonly></td>";     echo "<td><input name=weight size=5 value=$weight readonly></td>";     echo "<td><input name=price size=5 value=$bgprice readonly></td>";     echo "<td><input name=quantity size=5 value=0 tabindex=$i></td>";     echo "<td><input name=extprice size=5 value=0 readonly></td>";     echo "<td><input name=totalwt size=5 value=0 readonly></td>";     echo "</tr>";      $i++;     } 

i need javascript call function , calculate values extended price (extprice) , total weight (totalwt) user enters number of cases order.

here's struggle: there 30 items in dynamic table , each item's input name same. how can create function updates extprice , totalwt each individual product?

you use $i variable uniquely identify each input

echo "<td><input name=item id='item$i' size=5 value='$item' readonly></td>";

and side note use quotes or double quotes wrap $item may contains spaces, etc..


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -