Jump to content

JS cloning of a table row + calculating form entries -> can't get it to work together

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
bmett

bmett

    Newbie

  • Members
  • PipPip
  • 12 posts
Hello everyone,

My first post in this forum and I hope someone can help me out. I already found many code tips etc in here so I'm confident to find a solution for my problem.

In my site I use JS to clone Nodes of a HTML table (containing input fields). That works fine. I also managed to increment the ids of the cloned field so they don't stay the same as the id of the row I clone. Works fine.

Secondly I use a loop to go over all inputfields with a certain ID and calculate the values together. In the last row of the table is a field ('total') where the total of all rows is supposed to be calculated at onLoad and when pressing the button 'recalculate'. eg if the field values have been changed. This all works fine BUT (and here my problem starts):

The script won't calculate the values of the fields correctly for added rows. eg I add a couple of rows to the table with my clonenode script. after that I add values to the new input fields. Now I hit the recalculate button and I want all value to be added up and displayed in the total input field at the bottom of the table.
Unfortunately the values of newly added fields don't get added to total value.

WHY?

Alright, just read my post again and hope it's not to complicated and you guys actually understand what I want. :)
Thanks in advance.

Cheers,
Bjorn

#2
bmett

bmett

    Newbie

  • Members
  • PipPip
  • 12 posts
Back again,

I managed to help myself! I simply didn't rename the id of the new cloned input fields correctly!

Everything works fine now.

Cheers,
Bjorn