pb1uk Posted March 29, 2010 Report Share Posted March 29, 2010 Hello all, My problem is php/javascript, so i didn't know which board to post on! I have a table to update all records in a table in a database. The table displays fine and updates ok. However what i'm trying to do is add two values together in order to obtain the value to be input into the database. At the moment my code is: <form name="addgkscores" method="post" action="" > <table border="1"> <tr> <td>id</td> <td>gkname_gk</td> <td>PLD</td> <td>CLN</td> <td>points</td> </tr> <?php while($row_rs_test=mysql_fetch_array($rs_test)) { ?> <tr> <td><?php echo $row_rs_test['gkid_gk']; ?></td> <td><?php echo $row_rs_test['gkname_gk']; ?></td> <td><input type="text" id="p" size="3" value="0" /></td> <td><input type="text" id="c" size="3" value="0" /></td> <td><input name="foo[<?php echo $row_rs_test['gkid_gk']; ?>]" type="text" id="test" value="<?php echo $row_rs_test["$scoreweek"]; ?>" /></td> </tr> <?php } ?> </table> <input type="hidden" name="week" value="<?php echo $scoreweek; ?>"> <input type="button" name="addbutton" onclick="calculatescores(p.value, c.value)" value="add"/> <input type="submit" value="Insert scores" name="submit"/> </form> This is what i have upto now. I need to add the value of p to the value of c and return this value in the column id="test". I haven't included my javascript function as it doesn't work! I can get two fields to add up and return it in a blank field but because this is a dynamic table there are around 30 records in this table to update and i'm not sure how to do this for each one. I've searched around for a solution but have been unable to find anything. Any help would be brilliant. Thanks, pb1uk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.