onclick event does not work with select option in IE

P

prash.marne

Hello,

I have a simple form

<form method="POST">
<select name="activity">
<option value="0">None</option>
<option value="M" onclick="popup_onclick()">Select
Multiple</option>
<option value="1">Kayaking</option>
<option value="2">Rafting</option>
<option value="3">Snowboarding & Skiing</option>
<option value="4">Hiking</option>
<option value="5">Trekking</option>
</select>
</form>

& my javascript code is

function popup_onclick(){
my_window = window.open
("",'windowname','height=200,width=200');
my_window.document.write("hellow world");
my_window.document.close();
}

When a user views the form it shows a dropdown menu for activities &
when she/he clicks on 'Select Multiple' option a new window should pop
up with words written 'hellow world' in it .
This works fine in Firefox 1.5 but it doesn't work in IE (Internet
Explorer) 6.

Anyone have any tips ? Can this be done in IE 6 ? Thanks!

Prashant Marne
 
M

marss

Hello,

I have a simple form

<form method="POST">
<select name="activity">
<option value="0">None</option>
<option value="M" onclick="popup_onclick()">Select
Multiple</option>
<option value="1">Kayaking</option>

Hi,
Option element has no onclick event in IE. Use onchange event of select
element instead.

<select name="activity" onchange="if
(this.options[this.selectedIndex].value=='M') popup_onclick();">
<option value="0">None</option>
<option value="M">Select Multiple</option>
<option value="1">Kayaking</option>
......
 
P

prash.marne

marss,

thx for the reply. appreciate it. however, i'm a bit surprised why
internet explorer IE does not follow
the HTML specifications.

http://www.w3.org/TR/html401/interact/forms.html#h-17.6

it writes that the <OPTION> part of the <SELECT> element does have an
intrinsic event of onclick.

thanks.

prashant marne.

---------------------------------------------------------------------------------------------------------------------------------------------------------
OPTION Attribute definitions

selected [CI]
When set, this boolean attribute specifies that this option is
pre-selected.
value = cdata [CS]
This attribute specifies the initial value of the control. If this
attribute is not set, the initial value is set to the contents of the
OPTION element.
label = text [CS]
This attribute allows authors to specify a shorter label for an
option than the content of the OPTION element. When specified, user
agents should use the value of this attribute rather than the content
of the OPTION element as the option label.

Attributes defined elsewhere

* id, class (document-wide identifiers)
* lang (language information), dir (text direction)
* title (element title)
* style (inline style information)
* disabled (disabled input controls)
* onclick, ondblclick, onmousedown, onmouseup, onmouseover,
onmousemove, onmouseout, onkeypress, onkeydown, onkeyup (intrinsic
events)
---------------------------------------------------------------------------------------------------------------------------------------------------------

Hello,

I have a simple form

<form method="POST">
<select name="activity">
<option value="0">None</option>
<option value="M" onclick="popup_onclick()">Select
Multiple</option>
<option value="1">Kayaking</option>

Hi,
Option element has no onclick event in IE. Use onchange event of select
element instead.

<select name="activity" onchange="if
(this.options[this.selectedIndex].value=='M') popup_onclick();">
<option value="0">None</option>
<option value="M">Select Multiple</option>
<option value="1">Kayaking</option>
.....
 
B

Bart Van der Donck

ASM said:
(e-mail address removed) a écrit :

and what does mean "intrinsic" for you ?

clicking on an option intrinsically changes selectedIndex

Not necessarily. The option in question might be already selected when
clicked.
 
A

ASM

Bart Van der Donck a écrit :
Not necessarily. The option in question might be already selected when
clicked.

and ?

onclick changes selectedIndex to the same one :)
 
B

Bart Van der Donck

ASM said:
Bart Van der Donck a écrit :

and ?

onclick changes selectedIndex to the same one :)

The verb "to change" semantically means "to become different, or to
make different". A statement "change to the same" thus contradicts in
its terms by definition.
 
A

ASM

Bart Van der Donck a écrit :
The verb "to change" semantically means "to become different, or to
make different". A statement "change to the same" thus contradicts in
its terms by definition.

Don't think browsers think so far and
onclick=change ==> onclick = change to what asked
(even if not different)

But the way to change is not very important as soon as the result is
what was expected.
(any way last post was a joke and in previous one I used 'change' to
point to select's event 'onchange' doing an intrinsic parallel)
 

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

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top