Click to See Complete Forum and Search --> : Unable to get Value from insertCell element


kopite
08-20-2003, 11:23 AM
Hi,

I am unable to extract the value out of the input box that has been creating dynamically - how do I do this:

Code:

var tbl = document.getElementById("myTbl");
var tr = tbl.insertRow();
var td = tr.insertCell(0);

td.innerHTML = "<input type='text'>";
td.setAttribute("id","myCell");

I type in say "8998" into the box but how I can extract it as when I do this it returns "undefined"..

alert(document.getElementById("myCell").value) returns "undefined"

Help!

Khalid Ali
08-20-2003, 11:27 AM
you are setting the 'myCell" id for the TD not for the input element..you need to set the id for input element

kopite
08-20-2003, 11:35 AM
Apologies.. yep i put the id on the cell element instead of the input box element... took me a few hours to see that !!