”m trying to set the ID for dynamically created text box using JavaScript and code like fallows…
here QTY is Dropdown list
like..
HTML Code
<select id="Qty" name="childQty" onChange="changeIt()">
<option value="0">ZERO</option>
<option value="1">ONE</option>
<option value="2">TWO</option>
<option value="3">THREE</option>
<option value="4">FOUR</option>
<option value="5">FIVE</option>
</select>
<div id="my_div"><input type="hidden" /></div>
JavaScript Code
function changeIt()
{
var sel = document.getElementById('Qty');
var i = sel.options[sel.selectedIndex].value;
my_div.innerHTML ="";
var txtid="";
for(var j=0;j<i;j++){
txtid='mytext'+j;
//alert(txtid);
my_div.innerHTML = my_div.innerHTML +"<br><input type='text' name=txtid id='txtid'>"
}
}
Here am trying to set txtid to the id of that text boxes which are going to create inside my_div.innerHTML but this is not working txtid='mytext'+j; and then i want to concat those all text which user will enter in the dynamically created text boxes.
this Line:
should be