I am trying to create a dynamic form on my webpage. What I want to do is repeat this process multiple times on the same page. I know I have to have unique id's but I am not for sure how to set them.
Code:
// JavaScript Document
function addRowToTable(){
var tbl = document.getElementById('Division');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
// var iteration = lastRow + 1;
var row = tbl.insertRow(lastRow);
// cell 0
var cell0 = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.NAME = 'Resource[]';
el.size = 30;
cell0.appendChild(el);
//cell 1
var cell1 = row.insertCell(1);
var el = document.createElement("select");
cell1.innerHTML
+ '<option value="0">Avaliable</option>'
+ '<option value="1">Busy</option>'
//cell 2
var cell2 = row.insertCell(2);
var el = document.createElement('input');
el.type = 'text';
el.NAME = 'Comment[]';
el.size = 25;
cell2.appendChild(el);
}
Comment