Results 1 to 3 of 3
Thread: sum rows of textboxes
Aug 23, 2011, 07:26 #1
sum rows of textboxes
I have a table of textboxes which is dynamically create (based off the number of users and levels in my db).
I want the sum of each row to be 100 - the easiest way to ensure this is to update the row sum after any change in the textboxes.
The kicker is that I need to keep the user/level associations so that I can upload the new numbers to the database. Was thinking of using name="L5-U1" (level 5 - user 1) as the name attributes for each of the textboxes but unsure of how to sum the boxes using this method.
I'm not amazing at js and know I need to use loops, but what would be the best way to go about this?
After some further research, I think the best way is to assign the same class per row and add up all the textboxes in that class. What code would I use to auto-select the affiliated class? (e.g. I can't have a specific class listed in the function since they are dynamically generated, need to use "this" or pass the class name via onkeyup)
Aug 23, 2011, 08:31 #2
- Join Date
- Sep 2005
- 2 Post(s)
- 0 Thread(s)
Instead of trying to guess what you're trying to do (your requirements aren't very clear) it's better if you post some sample HTML so the structure is clear. Then describe exactly what you want.
Aug 23, 2011, 08:53 #3
Hopefully this is clearer.
Form looks like this ^
I need each row across to sum up to 100.
At the end, it needs to upload the new values into this db: