[thelist] JavaScript: Find matching number in list
Mike Carlson
mike at mcarlson.net
Thu May 12 07:24:31 CDT 2005
Sorry, I forgot to mention that I know how to concatenate, its the looking
of the string in another set of strings that I am having a problem with. I
will need to search through a list of a couple hundred possible options to
see if it matches what the user entered in the 3 drop downs.
--Mike
-----Original Message-----
From: Christian Heilmann [mailto:codepo8 at gmail.com]
Sent: Thursday, May 12, 2005 7:19 AM
To: mike at mcarlson.net; thelist at lists.evolt.org
Subject: Re: [thelist] JavaScript: Find matching number in list
> Howdy!
>
> I have 3 drop down menus and each item in the menu is assigned a number.
> After the user selects an option in each of the 3 drop downs, I need
> to concatenate those together and then compare that string to a list
> of 3 digit strings to see if there is a match in the list. If there
> isn't, bark at them, if there is submit the form.
>
> I am a newb in JS so I am looking at advice or examples that can help
> me out.
You get the current value of a select by checking its options, specifically
the selectedIndex one.
So if your selects are
<select id="se1" name="se1">
<select id="se2" name="se2">
<select id="se2" name="se2">
you concatenate by
var s1=document.getElementById('se1');
var s2=document.getElementById('se2');
var s3=document.getElementById('se3');
var
con=s1.options[s1.selectedIndex].value+s2.options[s2.selectedIndex].value+s3
.options[s3.selectedIndex].value;
then you compare con to your list and allow the form to be sent if there is
a value matching it.
--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/
More information about the thelist
mailing list