How can i get value from the nested textbox with same class?


Example i have two text box:

<input type="text" class="amount" >
<input type="text" class="amount" >


Can you post some more code? Are those input boxes each in an individual template?


If you’re trying to get all values from all inputs with same class, you could do it like this :

$( ".amount" ).val(function(index, value){
     // do what you need with those values here


@shad I try to use jquery like that but it sometime not work properly when no refresh page.


this is my code. actually this code is work. but it sometime calculate with the wrong value when there is no refresh page for about 30 minutes or more.

total = 0 ;
  $('.amount').each ->
     total += parseFloat $(this).val()


Can you elaborate ? How do you trigger it ?


it lookis like the picture below. I just want to iterate all the amount and calculate then put it into subtotal and total.
this is my code:

total = 0 ;
  $('.amount').each ->
    total += parseFloat $(this).val()


Don’t know how your code looks like behind, but you could simply trigger your calculations function each time the amount change in one of your row.


Actually that code is worked properly. but it just sometime calculated wrong. Anyway thanks so much. i will try to firgure out more.