SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict betrollwin.com's Avatar
    Join Date
    Nov 2005
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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)

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    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.

  3. #3
    SitePoint Addict betrollwin.com's Avatar
    Join Date
    Nov 2005
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:



    Question: How do I sum up each row via javascript (so that a person knows when a row totals 100) keeping in mind that tiers and users may change over time?
    Attached Images Attached Images


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •