Search code examples
javascriptjspstripes

Can I get values from hidden field doing something as below?


I have a table with rows. I have to get the row values. I am putting the row values in an array through JavaScript and then on submitting the form I am iterating the array and appending the vales to a hidden input text. The text input is mapped to my action class. Can I get the values, or my approach is wrong. I am facing some issues.

$.each(productList, function(idx, val) {
$('#hiddenField').append(val);
}); 

where hiddenField is property that I have mapped in my action class. Now can I get this input's value? Does append() append all the values of the list?


Solution

  • $.each(productList, function(idx, val) {
       var hidden = $('input[name="yourHiddenName"]');
       hidden.val(hidden.val()+val));
    });