I am trying to create a form based on user input. if the user answers yes to a question then more form elements appear below here is my code
[CODE]function add_row(table,number,text,name,type){
var row = table.insertRow(number);
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(text);
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(1);
var el = document.createElement(‘input’);
el.type = type;
el.name = name;
cellRight.appendChild(el);
}
function show_created(){
var tbl = document.getElementById(‘step1’);
var lastRow = tbl.rows.length;
if(lastRow==4){
add_row(tbl,4,”MySQL Username”,”mysql_user”,”text”);
add_row(tbl,5,”MySQL Password”,”mysql_pass”,”password”);
//create question row
var row = tbl.insertRow(6);
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(“Have you created a Database”);
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(1);
var el = document.createElement(‘input’);
el.type = “radio”;
el.name = “created_db”;
el.value = “yes”;
el.id = “created_db_yes”
cellRight.appendChild(el);
var el = document.createElement(‘label’);
el.for = “created_db_yes”;
el.innerHTML = “Yes”
cellRight.appendChild(el);
var el = document.createElement(‘input’);
el.type = “radio”;
el.name = “created_db”;
el.value = “no”;
el.id = “created_db_no”
cellRight.appendChild(el);
var el = document.createElement(‘label’);
el.for = “created_db_no”;
el.innerHTML = “No”
cellRight.appendChild(el);
}
}
it works and it creates 3 new rows on my table but the label tags don’t work when i looked at my page with firebug i see it created the label tag but left out the for info so when u click on the text nothing happens. what do i need to do do make the label tag work.
Scott.