Connecting Tech Pros Worldwide Forums | Help | Site Map

onclick event does not work with select option in IE

prash.marne@gmail.com
Guest
 
Posts: n/a
#1: Jan 18 '07
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


marss
Guest
 
Posts: n/a
#2: Jan 18 '07

re: onclick event does not work with select option in IE



prash.marne@gmail.com wrote:
Quote:
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>
......

prash.marne@gmail.com
Guest
 
Posts: n/a
#3: Jan 18 '07

re: onclick event does not work with select option in IE


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 <OPTIONpart of the <SELECTelement 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)
---------------------------------------------------------------------------------------------------------------------------------------------------------


marss wrote:
Quote:
prash.marne@gmail.com wrote:
Quote:
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>
.....
ASM
Guest
 
Posts: n/a
#4: Jan 18 '07

re: onclick event does not work with select option in IE


prash.marne@gmail.com a écrit :
Quote:
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 <OPTIONpart of the <SELECTelement does have an
intrinsic event of onclick.
and what does mean "intrinsic" for you ?

clicking on an option intrinsically changes selectedIndex

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Bart Van der Donck
Guest
 
Posts: n/a
#5: Jan 18 '07

re: onclick event does not work with select option in IE


ASM wrote:
Quote:
prash.marne@gmail.com a écrit :
Quote:
i'm a bit surprised why
http://www.w3.org/TR/html401/interact/forms.html#h-17.6

it writes that the <OPTIONpart of the <SELECTelement does have an
intrinsic event of onclick.
>
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.

--
Bart

ASM
Guest
 
Posts: n/a
#6: Jan 18 '07

re: onclick event does not work with select option in IE


Bart Van der Donck a écrit :
Quote:
ASM wrote:
Quote:
>>
> clicking on an option intrinsically changes selectedIndex
>
Not necessarily. The option in question might be already selected when
clicked.
and ?

onclick changes selectedIndex to the same one :-)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Bart Van der Donck
Guest
 
Posts: n/a
#7: Jan 18 '07

re: onclick event does not work with select option in IE


ASM wrote:
Quote:
Bart Van der Donck a écrit :
Quote:
ASM wrote:
Quote:
>
clicking on an option intrinsically changes selectedIndex
Not necessarily. The option in question might be already selected when
clicked.
>
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.

--
Bart

ASM
Guest
 
Posts: n/a
#8: Jan 18 '07

re: onclick event does not work with select option in IE


Bart Van der Donck a écrit :
Quote:
ASM wrote:
>
Quote:
>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.
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)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Closed Thread