<table class="privilage">
<caption> These are the default users for institution </caption>
<thead>
<tr>
<th>Users Name</th>
<th>User Id</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" name='DefaultUser[]' value='' ><br></td>
<td><input type="text" name='DefaultUser_UserName[]' value=''></td>
<td><input type="password" name='DefaultUser_Password[]'></td>
</tr>
<div id="New_User"></div>
</tbody>
</table> <table>
<tr>
<td><input type="button" name="Add_New_User" value="Add new User" onclick="addRow()"></td>
</tr>
</table>
The above HTML have a div named New_User, I asked the below javascript to print ussing innerHTML to that div, but it prints out elsewhere.
function addRow()
{
var d= document.getElementById("New_User");
d.innerHTML+="<tr><th><input type='text' name='DefaultUsers' value=''/> Manager<br></th><th><input type='text' name='UserName' value=''/></th><th><input type='password' name='Password'/></th></tr>";
}
I just need to add those new row to the ‘privilage’ table.
Any Consideration and help are welcome.
Thanks in Advance.
You can actually add new rows to your table without an extra Div inside it. You can use JS in-house functions to achieve this.
Also Please remove
<div id="New_User"></div>from your tbody, This makes your DOM structure invalid.Do this, Working demo : http://jsfiddle.net/epinapala/QPY6b/5/,
Add a new attribute id=”tableID” to your table though!