Hi I tryiing to modify a function that takes a number as a parameter and creates n Number of divs. The function uses insertBefore as a reference for where to insert the new code in the document. I am referencing a div layer “myDiv”, which is fine, but when the insertBefore function runs it can’t find the same div layer. Anyone have any suggestion? Thanks.
[CODE]function showAttendeesNew()
{
var mydiv = false;
var div = false;
var from = document.form;
var html = false;
var count = from.num_of_attend[from.num_of_attend.selectedIndex].value;
for (i = 1; i <= count; i++)
{
mydiv = document.getElementById(“myDiv”);
alert(mydiv);
div = document.createElement(“div”);
//div.setAttribute(“name”, “student”+i);
//div.setAttribute(“id”, “student”+i);
document.body.insertBefore(div, mydiv);
html = ‘<table width=”200″ style=”float:left;”>’;
html+= ‘<tr><td><label for=”fname”>First Name:</label><br /><input type=”text” id=”fname[]” name=”fname” /></td></tr>’;
html+= ‘<tr><td><label for=”lname”>Last Name:</label><br /><input type=”text” id=”lname[]” name=”lname” /></td></tr>’;
html+= ‘<tr><td><label for=”email”>Email:</label><br /><input type=”text” id=”email” name=”email[]” class=”required validate-email” title=”Enter your username” /></td></tr>’;
html+= ‘<tr><td><label for=”credits”><input type=”checkbox” id=”credits” name=”credits” />Would you like to receive Continuing Education Credit?</label></td></tr>’;
html+= ‘<tr id=”rec_credit_license”><td>License Number:<br /><input type=”text” value=”” name=”lic_num[]” size=”20″ maxlength=”30″ /></td> </tr>’;
html+= ‘</table>’;
div.innerHTML = html;
}
}