I dynamically append rows into a table using javascript functions.
Add row function:
function addrow(tableid) {
var tablename = document.getElementById(tableid);
var rows = tablename.rows.length;
if (rows < 8) { //Maximum number of rows allowed
var newrow = tablename.insertRow(rows);
var col = tablename.rows[0].cells.length;
for (var i=0; i<col; i++) {
var newcell = newrow.insertCell(i);
newcell.innerHTML = tablename.rows[0].cells[i].innerHTML;
}
}
else {
alert(" Maximum number of rows allowed is 8");
}
}
HTML Code (row structure) :
<tr>
<p>
<td width="20%">
<input class="input-group-lg" type="text" name="c_degree[]" style="width:90%"/>
</td>
<td width="25%">
<input class="input-group-lg" type="text" name="c_specialization[]" style="width:90%" />
</td>
<td width="30%">
<input class="input-group-lg" type="text" name="c_university[]" style="width:90%" />
</td>
<td width="15%">
<input class="input-group-lg" type="number" name="c_year[]" min="1990" max="2015" />
</td>
<td width="10%">
<input class="input-group-lg" type="number" name="c_marks[]" min="1" max="100" />
</td>
</p>
</tr>
I need to pass data(these arrays) from all the dynamically created rows to an ajax script(which delivers it to the back end).
<p>inside a<tr>in not valid.See this. "A<tr>element contains one or more<th>or<td>elements." So basically, you want to know how to grab all this dynamic data, as an object for example? That way you can pass it to your Ajax function?