I'm relatively new to web development, what i'm trying to achieve is an array of all the input values of the current row for each row found, for example: test1, true
While i'm able to get the dynamically created input values, i end up with a bunch of blanks, possibly headers? I'm also not sure my method of obtaining the values is the best solution either. Here is what i have so far: http://jsfiddle.net/gcL9H/2/
<table id='categoriesTable' border='1'>
<tr>
<th>Category</th>
<th>X</th>
</tr>
<tr id='data'>
<td><input value='test1' type='text' /></td>
<td><input type='checkbox' /></td>
</tr>
</table>
<button id="addRow">Add</button>
<button id="saveCategories">Results</button>
$('#addRow').click(function()
{
$('#categoriesTable').append("<tr></tr><tr></tr><td><input type='text'/></td><td><input type='checkbox'/></td>");
});
$('#saveCategories').click(function()
{
$("#categoriesTable tr").each(function()
{
var row = [];
$(this).find('td').each(function()
{
var type = $(this).find('input').attr('type');
if(type == "text")
row.push($(this).find('input').val());
else
if(type == "checkbox")
row.push($(this).find('input').is(":checked"));
})
alert(row);
})
});
Thanks in advance.
<tr>tags in youraddRowclick handler?