Here's the function I have to create a div with some text inputs in it. I believe the use of innerHTML has been deprecated (or maybe just frowned upon) so I was wondering how I could do it with createElement or something, I would also like to put the inputs into an array for each, e.g. Ename[], Eposition[], so that multiple divs just put the same inputs into an array.
Here's the function I have so far:
Any thoughts?
Here's the function I have so far:
Code:
function createDiv()
{
var divTag = document.createElement("div");
var mydiv = document.getElementById("empBigDiv");
divTag.setAttribute("align","center");
divTag.style.margin = "0px auto";
divTag.className ="dynamicDiv";
divTag.innerHTML = "<label for=\"Ename\">Name: <input type=\"text\" style=\"display: inline;\" name=\"Ename\" size=\"20\"></label> Address: <input type=\"text\" style=\"display: inline;\" name=\"Eaddress\" size=\"20\"> Position: <input type=\"text\" style=\"display: inline;\" name=\"Eposition\" size=\"20\"><br>";
divTag.innerHTML += "Reason for Leaving: <input type=\"text\" name=\"Ereason\" size=\"20\"> Employed From: <input type=\"text\" name=\"Efrom\" size=\"20\"> Employed To: <input type=\"text\" name=\"Eto\" size=\"20\"><br>";
mydiv.appendChild(divTag);
}
Any thoughts?