Jump to content

Sum of Arrays within Arrays using jquery and javascript


neilfurry

Recommended Posts

Hello,

 

Im hoping to get help from here,

 

i have arrays of text fields that i need to get sums,..

 

<div class='fldgroup'>

<input type="text" name="fld[0]">

<input type="text" name="fld[0]">

<input type="text" name="fld[0]">

<input type="text" name="sumfld[0]">

<button>Add Another Field</button>

 

 

<input type="text" name="fld[1]">

<input type="text" name="fld[1]">

<input type="text" name="fld[1]">

<input type="text" name="sumfld[1]">

<button>Add Another Field</button>

</div>

 

<button>Add Another Group</button>

 

 

how can i get the sum of all fld[0] and put it to sumfld[0] same as the fld[1] to sumfld[1],.. every text field is dynamically added using clone.,

 

i hope somebody can help me with this....

 

Thank you in advance...

Link to comment
Share on other sites

im wrong with the group structure. here is the correct grouping of array.

 

<div class='fldgroup'>

<input type="text" name="fld[0]">

<input type="text" name="fld[0]">

<input type="text" name="fld[0]">

<input type="text" name="sumfld[0]">

<button>Add Another Field</button>

</div>

 

<div class='fldgroup'>

<input type="text" name="fld[1]">

<input type="text" name="fld[1]">

<input type="text" name="fld[1]">

<input type="text" name="sumfld[1]">

<button>Add Another Field</button>

</div>

 

<button>Add Another  Field Group</button>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.