2

am creating the row dynamically in html table using id of input field in td of that table. table created properly with newly added rows and input box ids also created.but when I try to get that input box using id it throws null exception.

var cell1 = row.insertCell(1);
var element1 = document.createElement("input");
    element1.name = rId + "_" + rowCount + "_newscheduledate";
    element1.id = rId + "_" + rowCount + "_newschedueldate";
    cell1.appendChild(element1);

     alert(rowCount+"  : "+rId);  //here alert shows the values
     var tt = document.getElementById(rId + '_' + rowCount + '_newscheduledate');
     alert(tt); // here null comes

Exception comes like this

Error: document.getElementById(rId + ("_" + rowCount + "_newscheduledate")) is null
sunleo
  • 10,589
  • 35
  • 116
  • 196

2 Answers2

1

Change:-

element1.id = rId + "_" + rowCount + "_newschedueldate";

To

element1.id = rId + "_" + rowCount + "_newscheduledate";
Paul Alan Taylor
  • 10,474
  • 1
  • 26
  • 42
  • sorry for asking I didn't find any difference between this 2 lines code. Please help me to get clarification. – sunleo Feb 23 '13 at 08:55
1

You have an spelling mistake in

element1.id = rId + "_" + rowCount + "_newschedueldate";

need to be

element1.id = rId + "_" + rowCount + "_newscheduledate";