Reputation: 291
Rows (id='row_property_'+number) in table contain four columns :
How to iterate through each row and collect data in two arrays from select and input with jquery ?
Upvotes: 1
Views: 563
Reputation: 35793
var selectArray = $('table tr td > select').map(function() {
return $(this).val();
}).get();
var inputArray = $('table tr td > input:text').map(function() {
return $(this).val();
}).get();
This might do what you want.
Upvotes: 0
Reputation: 29925
Ok, add classes to the select and input elements so that the table looks something like this:
<table id="myTable">
<tr>
<td><select class="rowSelect"></select></td>
<td><input type="text" class="rowInput" /></td>
... etc ...
</tr>
</table>
Then you can get the values from each row like this in jquery:
$(function(){
$('#myTable tr').each(function(){
alert('select value is '+$(this).find('select.rowSelect'));
alert('input value is '+$(this).find('input.rowInput'));
});
});
Upvotes: 1