Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14109
| From | "Mel Smith" <med_cutout_syntel@aol.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Accessing a <select> <option> ? |
| Date | 2012-05-23 13:42 -0600 |
| Message-ID | <a24su6Fd3rU1@mid.individual.net> (permalink) |
| References | <a2273uFft7U1@mid.individual.net> <4fbd37ba$0$21484$ba4acef3@reader.news.orange.fr> |
Stephane a dit:
>
> I thinck you can't attribute an onclick to an option
> the onclick is for the all select (as 'onchange' for instance)
>
>
> so I think you must use something like :
>
> <select onchange="myFunction(this)">
> <option>
> <option>
> ...
>
> function myFunction(what) {
> var i = what.selectedIndex,
> k = what.options[i].value;
> alert(k);
> switch(i) {
> case 0: doThat(); break;
> case 3: doThis(); break;
> }
> }
Hi Stephane:
Yes, I'm doing the above now successfully, but thanks for your response
!
(btw, I'm posting another question in a few minutes re: auto-scrolling
of <option>s in a <select> list.)
-Mel Smith
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Accessing a <select> <option> ? "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-22 13:18 -0600
Re: Accessing a <select> <option> ? "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-22 13:43 -0600
Re: Accessing a <select> <option> ? Matt McDonald <matt@fortybelow.ca> - 2012-05-22 14:43 -0600
Re: Accessing a <select> <option> ? "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-22 15:09 -0600
Re: Accessing a <select> <option> ? "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-22 20:26 -0600
Re: Accessing a <select> <option> ? SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-05-23 21:17 +0200
Re: Accessing a <select> <option> ? "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-23 13:42 -0600
Re: Accessing a <select> <option> ? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-23 21:17 +0000
csiph-web