N
Nicholas Couch
I have a little form with a couple of dynamically generated list
boxes. When the user makes a selection from the first box, the second
box is refreshed. When they make a selection from the second box, I
concatenate the selections from the two boxes and add the string to a
list at the top of the form, using createElement and appendChild. The
list is actually a bunch of span elements contained within a div. Each
span element includes a small graphic of a red X, which the user can
click to delete that item from the list.
All of this works just fine in Mozilla and Opera, but - wait for it -
the delete functionality fails in IE, throwing an "Object Required"
error on this line:
this.style = document.getElementById(nm).style;
where nm is the ID of the span element I'm trying to hide, by setting
it's display property to "none."
What's really interesting is the fact that I have one or more span
elements in that div when the form first loads, and IE will hide these
HTML-based elements without complaining. It's only the spans that I
generate on the fly that it has a problem hiding.
Must be something wrong with the way I'm creating those dynamic spans,
you say? Maybe so, but IE does display them okay, and the code all
works great in the other two browsers. Now I'm no javascript veteran,
by any means, but this appears to me to be a bug in IE. What I asking
here is whether anybody knows of a workaround for this, or maybe a
better way of accomplishing what I'm trying to do.
Thanks in advance,
Blake Couch
Javascript Noob
boxes. When the user makes a selection from the first box, the second
box is refreshed. When they make a selection from the second box, I
concatenate the selections from the two boxes and add the string to a
list at the top of the form, using createElement and appendChild. The
list is actually a bunch of span elements contained within a div. Each
span element includes a small graphic of a red X, which the user can
click to delete that item from the list.
All of this works just fine in Mozilla and Opera, but - wait for it -
the delete functionality fails in IE, throwing an "Object Required"
error on this line:
this.style = document.getElementById(nm).style;
where nm is the ID of the span element I'm trying to hide, by setting
it's display property to "none."
What's really interesting is the fact that I have one or more span
elements in that div when the form first loads, and IE will hide these
HTML-based elements without complaining. It's only the spans that I
generate on the fly that it has a problem hiding.
Must be something wrong with the way I'm creating those dynamic spans,
you say? Maybe so, but IE does display them okay, and the code all
works great in the other two browsers. Now I'm no javascript veteran,
by any means, but this appears to me to be a bug in IE. What I asking
here is whether anybody knows of a workaround for this, or maybe a
better way of accomplishing what I'm trying to do.
Thanks in advance,
Blake Couch
Javascript Noob