I’ve got some JavaScript that works great in Gecko browsers and Firefox, but doesn’t work completely in IE. It is supposed to create a new field, then set focus to the field. In IE, it doesn’t set focus to the field.
Anyone know of a fix or a work-around?
Your jacking up the id.
When you set the newField.id’field_’ + count; you’re actually setting it on the ‘P’ element that you created. so you now have two elements with that id, the p and the input. Try this:
basically after the for loop do this:
inputId’field_’+ count;
newField.id’p_’ + count;
newField.innerHTML = newField.innerHTML.replace(/##COUNTER##/g, count);
document.getElementById(‘wrapper’).appendChild(newField);
document.getElementById(inputId).focus();
but really you might want to create the input using the createElement method and then set the id, after you know the count, you won’t have to do the ##COUNTER replacement
Ahh, you’re right! Thanks Luke.
check this:
http://www.eldub.com[...]reation.html
Very cool Luke, thanks. Just FYI – a couple of your changes (for example, relying on a JS value for the # of fields) won’t work in my real life use case as there may be existing fields already to which I need to append the new fields (numbered accordingly). Regardless, yours has the added benefit of actually working. 😉