Script question....
-
Hi. How can I transform this javascript code function insRow() { var x=document.getElementById('myTable').insertRow(0) var y=x.insertCell(0) var z=x.insertCell(1) y.innerHTML="NEW CELL1" z.innerHTML="NEW CELL2" }
Row1 cell1
Row1 cell2
Row2 cell1
Row2 cell2
Row3 cell1
Row3 cell2
so values NEW CELL1 and NEW CELL2 can be inserted by user in two different textboxes.
-
Hi. How can I transform this javascript code function insRow() { var x=document.getElementById('myTable').insertRow(0) var y=x.insertCell(0) var z=x.insertCell(1) y.innerHTML="NEW CELL1" z.innerHTML="NEW CELL2" }
Row1 cell1
Row1 cell2
Row2 cell1
Row2 cell2
Row3 cell1
Row3 cell2
so values NEW CELL1 and NEW CELL2 can be inserted by user in two different textboxes.
Firstly the removed in your Insert row button should be onClick. That's the event that gets called when you click the button, and executes your insRow() function. It not clear to me what you want when you say "so values NEW CELL1 and NEW CELL2 can be inserted by user in two different textboxes". With onClick instead of removed in your button, the code inserts a two new cells into your table. Are these the two different textboxes you are refering to? If not then you need to add them to your page, either using javascript or as HTML tags, similar to the way you created the button. Then, assuming that the textboxs you add have ids of textbox1 and textbox2, it's just a matter of adding statements like this to your insRow() function:
textbox1.value = "NEW CELL1"; textbox2.value = "NEW CELL2";