function click_section(d, section_name) { var section = null; var i, len = sections.length; var x, perm_len = permissions.length; var div, chk, p, td = document.getElementById("perm_list"); if (open_section) section = open_section; open_section = d; td.innerHTML = ""; div = document.createElement("DIV"); div.className = "perm_list"; for (i = 0; i < len; i++) { p = document.createElement("P"); chk = document.createElement("INPUT"); chk.type = "checkbox" chk.name = "perm_"+ sections[i].id; for (x = 0; x < perm_len; x++) { if (permissions[x] == sections[i].id) { chk.checked = true; break; } } p.appendChild( chk ); p.appendChild( document.createTextNode( sections[i].name ) ); div.appendChild( p ); td.appendChild( div ); } alert(td.innerHTML); if (section) roll_off_section( section ); }