PDA

View Full Version : Weird JS problem


sdustinh
02-13-2008, 08:36 PM
Alright, I've got this script I'm working on. When you select one of the options from the pull down box, it will replace the select with a text input field. Here is the section of code I'm using for that:

var customMP = document.getElementById("part_mp");
var newCustomMP = document.createElement("input");

newCustomMP.setAttribute("id", "part_mp");
newCustomMP.setAttribute("size", "12");
newCustomMP.setAttribute("name", "mountpoint");
newCustomMP.setAttribute("type", "text");
newCustomMP.setAttribute("value", setMP);

thePartPopup.replaceChild(newCustomMP, customMP);
newCustomMP.focus();

This works fine in Safari and FF, but in IE when the option is selected it doesn't replace it with the text input. Even more, it doesn't even spit out and error or reason why it doesn't switch them out. I'm hoping someone on here knows why. I've had problems with IE and setAttribute() but it's always spit out an error. Thanks for the help.

shyam
02-13-2008, 08:53 PM
I'm using IE6 and it worked for me (I only changed customMP.parentNode.replaceChild(newCustomMP, customMP) so that i did not have to define thePartPopup)

sdustinh
02-13-2008, 09:08 PM
I just tested it in IE7, and it doesn't work. I can't understand why not though. If it works in IE6, Safari 3, Safari 3 (windows), FF (win&mac), but IE 7 is giving me grief... have there been any changes? I just don't know why it wouldn't at least give me an error or something.

shyam
02-13-2008, 09:16 PM
looks like you're matching wits against a known bug http://www.quirksmode.org/blog/archives/2006/04/explorer_refuse.html

sdustinh
02-13-2008, 09:46 PM
BAH! Thanks, I saw that and was crossing my fingers it didn't apply. Haha.

Well, I guess I've got to figure something else out. :(