Re: IE, getAttribute, search, and selects

Tony Mechelynck <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
Philip Thompson wrote:
> I'm racking my brain over this one. IE is being mean again. I am getting
> the errors "Object doesn't support this property or method" and "Could
> not complete the operation due to error 80020101." I did searches for
> these, but none of those specific problems seemed to apply to me. Here's
> my (condensed) JS - what's wrong?!
>
> <js>
> function updateRequiredField (id) {
> var element = document.getElementById(id);
> var onchange = element.getAttribute('onchange');
> var action = "updateRequiredField('"+id+"');";
> ...
> if (element && element.options) {
> // If a select box
> if (onchange) {
> alert(element.name+' onchange: '+onchange);
>
> if (onchange.search('updateRequiredField') == -1) {
> onchange = onchange ? onchange + action : action;
> element.setAttribute('onchange', onchange);
> }
> } else if (!onchange) {
> element.setAttribute('onchange', action);
> }
> }
> ...
> }
> </js>
>
> IE breaks on line 11 - "if (onchange.search...". When alert'ing the
> onchange string in IE, I get: "function anonymous() { aFunctionName();
> }". In FF, I get: "aFunctionName();" and it works fine. Where is that
> "function anonymous" coming from?
>
> What I'm wanting to do is dynamically add an onchange event. This event
> function will then run validation on the form field. Any helpful hints
> on what's happening would be greatly appreciated!
>
> Thanks,
> ~Philip

There is no mention of <js> in my HTML reference. Is it synonymous to 
<script type="javascript"> ? Or did I misinterpret you?

Oh, and by the way, maybe a Microsoft newsgroup ( 
nntp://msnews.microsoft.com/* IIRC) or a general Usenet group about 
javascript, would be better suited for this question.


Best regards,
Tony.
-- 
With every passing hour our solar system comes forty-three thousand
miles closer to globular cluster M13 in the constellation Hercules, and
still there are some misfits who continue to insist that there is no
such thing as progress.
		-- Ransom K. Ferm
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.