I have dynamically generated textboxes. I want to assign names and id to the textboxes and also retrieve the values of dynamically generated textboxes to insert into database. How can it be done?
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<select id="sel2" multiple>
<option value="first">first option</option>
<option value="second">sec option</option>
<option value="third">third option</option>
<option value="fourth">fourth option</option>
<option value="fifth">fifth option</option>
<option value="sixth">six option</option>
</select>
<table id="tab2">
<tbody>
</tbody>
</table>
<button id="add" value="Add">Add</button>
<script>
$(document).ready(function()
{
$("#add").click(function()
{
var selectval = $('#sel2').val();
var len = selectval.length;
for(var i=0; i < len; i++){
$("#tab2 tbody").append("<tr><td>"+selectval[i]+"</td><td><input type='text'</td></tr>");
}
});
});
</script>