Which events fire reliable in IE6 <select>?

A

andreas.maurer1971

Hi everybody,

I nearly get despaired of the fact that the events I chose and,
according to the MSDN site, are correct, don't fire reliable in IE6.
Is someone able to tell me, which events I can use for the following
situation?

I have a <select> list with dynamically generated options. Latest when
I have changed the (pre-) selected option and loose the focus of the
select-list I want to run a function to find out about the newly
selected option and act accordingly.

I tried the events onblur = somefunction(), onfocus = somefunction(),
onselect = somefunction() and even onselectstart = somefunction() and
used them like follows:

<SELECT ID="IDNAME" SIZE="1" ONFOCUS="somefunction()"
ONBLUR="somefunction()"></SELECT> in nearly every combination, e.g.
only onfocus or combined as above and with and without the "" around
somefunction().

Unfortunately with neither event somefunction() gets called.

Please note that the solution only has to work in IE6 and not in other
browsers.

Thank you very much in advance,

Andy
 
V

VK

Hi everybody,
[EDIT]

I forgot to mention that this <select> box is within a frameset.
Just in case that this matters.

Where do you process the events? In the frame with <select> list or in
some other frame? If in some other frame and these are frames from
different domains then you cannot capture events with default security
settings.

Just to check that your system works:

<select name="foo" onchange="alert(this.selectedIndex)">
<option selected>1</option>
<option>2</option>
<option>3</option>
</select>

Copy'n'paste as it is into your form and select something. See if alert
pops up.
 
A

andreas.maurer1971

VK said:
Just to check that your system works:

<select name="foo" onchange="alert(this.selectedIndex)">
<option selected>1</option>
<option>2</option>
<option>3</option>
</select>

Copy'n'paste as it is into your form and select something. See if alert
pops up.

Hi VK,

thank you for your answer.
I have copied your code into my HTML- file and it works.
Doing the same (simply changeing the function call to the alert(...))
within my <select> list doesn't work.

Could it be that it has something to do with my dynamical creation of
the <option>- tags?

this.IDNAME[0] = new Option("some text", 0 , true, false); // default
selected
this.IDNAME[1] = new Option("some other text", 0 , false, false);
for (var i = 2; i < 10 ; i++) {
this.IDNAME = new Option("some more text", i, false, false); //
some more text is just an example and displays well ;-)
}

I process the event in the same html-file and therefore the same frame.
The function origially was located at the end of the file but now I
have moved it to the <head> part of it. Thank's for asking where I
process it. This might have been another, more difficult to find
mistake.

Andy
 
A

andreas.maurer1971

VK schrieb:

Hi VK and everyone,

the problem is solved.

The reason for it was that I had a second <select> - tag with the same
id just a few lines above the "real" tag due to some copy/paste.
Of course IE got confused and didn't know where it was.

Sorry for wasting your time but trust me, if a colleague wouldn't have
looked over my shoulders and asked me what the second tag is good for I
never would have found it although I already spent literally hours on
this problem.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top