Generate rows using javascript

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);

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

el.onkeypress = keyPressTest;

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

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

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

<?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:

Not sure if you are into jQuery, but this would be trivial do with it. jQuery has a function called clone() that will clone/copy any element. I've used it data entry table, that it will automatically add a new row when someone has filled the last available line.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.