Welcome Guest, Not a member yet? Register   Sign In
Generate rows using javascript
#1

[eluser]canicasio[/eluser]
Hello, im new using CI and i have a problem:

I have a view and in it, i generate rows for a table using javascript. In that table i have a "select" that present information from a D.B, but it does not prensent all the information form de D.B. only the last record. Here is the code:

function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);

// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;
el.size = 40;

el.onkeypress = keyPressTest;
cellRight.appendChild(el);

// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');

sel.name = 'selRow' + iteration;


<?php foreach($seleccion as $item):?>

sel.options[0] = new Option('<?php echo $item->DESCRIPCION;?>');
cellRightSel.appendChild(sel);

<?php endforeach;?>

}



$seleccion is an array that has the information from the B.D

for more information please see in the following link what i want to do:

http://www.mredkj.com/tutorials/tableaddrow.html


Messages In This Thread
Generate rows using javascript - by El Forum - 06-20-2010, 09:58 AM
Generate rows using javascript - by El Forum - 06-20-2010, 02:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB