vkkumar
09-04-2006, 08:00 AM
I Do Not Know Where I am going WRONG . . .
I am facing a problem as mentioned below -
I have a "myscripts.js" file in which there is a function which adds a row to a table on the fly with form elements like checkbox, file input etc.
I want to add a listbox which has numbers 1 to 100 - to that row of the TABLE.
The code in my "myscripts.js" file is somewhat as shown below -
function addRowToTable(num)
{
if (hasLoaded) {
var tbl = document.getElementById(TABLE_NAME);
var nextRow = tbl.tBodies[0].rows.length;
var iteration = nextRow + ROW_BASE;
if (num == null) {
num = nextRow;
} else {
iteration = num + ROW_BASE;
}
// add the row
var row = tbl.tBodies[0].insertRow(num);
//*************** THE PROBLEM AREA *****************
var cell0 = row.insertCell(0);
var qtEl = document.createElement('select');
qtEl.setAttribute('name', 'myqty' + iteration);
for(var j=1;j<=100;i++) {
var qtOption=document.createElement('OPTION');
var qtText=document.createTextNode(j);
qtOption.appendChild(qtText);
qtOption.setAttribute('value',j);
qtEl.appendChild(qtOption);
}
cell0.appendChild(qtEl);
}
}
Please hep me . . .
Thank You
I am facing a problem as mentioned below -
I have a "myscripts.js" file in which there is a function which adds a row to a table on the fly with form elements like checkbox, file input etc.
I want to add a listbox which has numbers 1 to 100 - to that row of the TABLE.
The code in my "myscripts.js" file is somewhat as shown below -
function addRowToTable(num)
{
if (hasLoaded) {
var tbl = document.getElementById(TABLE_NAME);
var nextRow = tbl.tBodies[0].rows.length;
var iteration = nextRow + ROW_BASE;
if (num == null) {
num = nextRow;
} else {
iteration = num + ROW_BASE;
}
// add the row
var row = tbl.tBodies[0].insertRow(num);
//*************** THE PROBLEM AREA *****************
var cell0 = row.insertCell(0);
var qtEl = document.createElement('select');
qtEl.setAttribute('name', 'myqty' + iteration);
for(var j=1;j<=100;i++) {
var qtOption=document.createElement('OPTION');
var qtText=document.createTextNode(j);
qtOption.appendChild(qtText);
qtOption.setAttribute('value',j);
qtEl.appendChild(qtOption);
}
cell0.appendChild(qtEl);
}
}
Please hep me . . .
Thank You