[thelist] Jump to entry in select box?

Raymond K. Camden rcamden at allaire.com
Wed Nov 22 09:44:00 CST 2000


This code will handle that.

I believe that addressing the form by name, document.Foo, is a 4.x only
convention. If this is the only form on the page, you can replace it with
document.forms[0], or, if it's the Xth form, use X-1 instead of 0.

<FORM NAME="Foo">

<INPUT TYPE="checkbox" NAME="doit"
VALUE="Auto" onClick="for(i=0;i<document.Foo.MyDropDown.options.length;i++)
{ if(document.Foo.MyDropDown.options[i].value == 9)
document.Foo.MyDropDown.options[i].selected = i; }">Auto select something
<P>
<SELECT NAME="MyDropDown">

<OPTION VALUE="1">Luke
<OPTION VALUE="3">Darth
<OPTION VALUE=9>Han
</SELECT>

</FORM>

=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Allaire

Email   : jedimaster at allaire.com
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda


> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of Mike.Hodgson
> Sent: Wednesday, November 22, 2000 6:45 AM
> To: thelist at lists.evolt.org
> Subject: [thelist] Jump to entry in select box?
>
>
> Hi guys,
>
> I'm trying to fumble my way round a bit of javascript and am
> wondering it's
> possible to jump (using onClick in a checkbox) to a specific entry in a
> pulldown list based on the *value* of the entry.  I know I can jump to a
> specific entry in the options *array* using something like:
>
> <form name="form1">
> 	<input type="checkbox"
> onClick="document.form1.pulldown.options[2].selected=true">
> 	<select name="pulldown">
> 		<option value="">choose one...
> 		<option value="2">Mick
> 		<option value="37">Sean
> 		<option value="9">Chris
> 		<option value="1">Mark
> 	</select>
> 	<input type="submit">
> </form>
>
> which will jump to "Sean".  Is there a way I can jump to "Chris" by
> referring to the number "9"???
>
> I hope that made sense.
> Cheers,
> Mick
> PS: a cc to my email address would be great as I'm on the digest.
>
>  
> ----------------------------------------------------------------
>       Visit our Internet site at http://www.citywatch.co.uk
>  
> Any views expressed in this message are those of the individual
> sender, except where the sender specifically states them to be
> the views of Citywatch Ltd.
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list