f



select: how to detect same option selected?

onChange() is working very well, when an option is choosen the first
time. how can i detect when the user clicks and choose the same option
again?
this code works with IE 6.x. you can click the same option again and
again and the onChange()-event comes up.
firefox will react on the onmousedown but the onChange is not executed.

is there a way to detect selecting the same option again and again?

<html>
<head>
	<script>
		function selChange (feld) {
			alert (feld.options[feld.selectedIndex].value);
		}
	</script>
</head>

<body>
<FORM>
	<SELECT onmousedown="this.selectedIndex=-1; this.focus(); return
true;" onchange="selChange(this); return false;">
		<OPTION VALUE="nop">Choose
		<OPTION VALUE="1">one
		<OPTION VALUE="2">two
		<OPTION VALUE="3" selected>three
		<OPTION VALUE="4">four
	</SELECT>
</FORM>
 </body>
</html>

0
4/23/2006 1:28:03 PM
comp.lang.javascript 38370 articles. 2 followers. javascript4 (1315) is leader. Post Follow

4 Replies
656 Views

Similar Articles

[PageSpeed] 25

markus.rietzler@rzf.fin-nrw.de said the following on 4/23/2006 9:28 AM:
> onChange() is working very well, when an option is choosen the first
> time. how can i detect when the user clicks and choose the same option
> again?
> this code works with IE 6.x. you can click the same option again and
> again and the onChange()-event comes up.
> firefox will react on the onmousedown but the onChange is not executed.
> 
> is there a way to detect selecting the same option again and again?

<snip>

> <FORM>
> 	<SELECT onmousedown="this.selectedIndex=-1; this.focus(); return
> true;" onchange="selChange(this); return false;">

onmouseup = "selChange(this)"

I bet it makes keyboard navigation fun......

-- 
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
0
Randy
4/23/2006 2:53:39 PM
markus.rietzler@rzf.fin-nrw.de wrote:
> onChange() is working very well, when an option is choosen the first
> time. how can i detect when the user clicks and choose the same option
> again?
> this code works with IE 6.x. you can click the same option again and
> again and the onChange()-event comes up.
> firefox will react on the onmousedown but the onChange is not executed.
> 
> is there a way to detect selecting the same option again and again?

Perhaps see this Aug 15, 2005 thread:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/618645fa2fe904be/

Csaba Gabor from Vienna
0
Csaba
4/23/2006 3:19:57 PM
@randy: even with a mouse the select is not usable anymore.

@csaba: my problem is, that i want to react even if the same option is
selected again! say reload the page and send the "select-option-value"
again. 

markus

0
markus
4/23/2006 4:38:43 PM
markus.rietzler@rzf.fin-nrw.de wrote:

> onChange() is working very well, when an option is choosen the first
> time. how can i detect when the user clicks and choose the same option
> again?
> this code works with IE 6.x. you can click the same option again and
> again and the onChange()-event comes up.
> firefox will react on the onmousedown but the onChange is not executed.
> 
> is there a way to detect selecting the same option again and again?

onclick.  (However, don't use `select' elements for navigation without
fallback; use `ul' and a[href] elements instead.)

> @randy: even with a mouse the select is not usable anymore.
 
I do not understand -- maybe because you did not quote anything.
See below.

> [<html>...</html>]

<URL:http://validator.w3.org/>


PointedEars

P.S.
Please learn to post.  Your current style does not do anyone any good:

[en] <URL:http://jibbering.com/faq/faq_notes/pots1.html>
[en] <URL:http://www.safalra.com/special/googlegroupsreply/>
[de] news:de-newusers-infos/google-poster/20060421-1@krell.zikzak.de

P.P.S.: Did you know that there is de.comp.lang.javascript?
-- 
The English government is much of a German poodle as
other governments.  The Germans infiltrated them all.
  -- "The only real Barbara Schwarz", dsw.scientology,
     <16d1deb5.0402261008.48f994b6@posting.google.com>)
0
Thomas
4/23/2006 8:37:06 PM
Reply: