Hello, I have done this successfully in firefox, but I need to do this in IE now, I want to dynamically generate an id for my input elements for an element being created. So far I can't get the id to come out correctly, here is what I have:

var i = 1;
while(i < 10)
{
var rowItem = document.createElement("<input type=text id=['up' + i]>");
tdItem.appendChild(rowItem);
i++;
}

so I would want the id's for my input elements to be up1, up2, up3, up4, etc.

var rowItem = document.createElement("<input type=text id=['up' + i]>");

try this:

var inputid = "up" + i;
var rowItem = document.createElement('<input type="text" id="' + inputid + '">');

and according to what I've read here, you need to provide valid html for ie, yet that will throw an error in ff so you will have to check the browser type, refer here http://www.byteclub.net/wiki/index.php?title=Javascript_createElement

Thanks! That got it working, it works in both IE and Firefox, in Firefox I had to do

var rowItem = document.createElement('input');
rowItem.setAttribute('type', 'text');
rowItem.setAttribute('id', ['item' + l]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.