[Javascript] select list option sending

Robert Pollard rpollard at apple.com
Thu Oct 9 13:32:16 CDT 2003


On Thursday, October 9, 2003, at 11:11 AM, David S Levy wrote:

> Hey.  I'm trying to make a dropdown(select) list of locations in a 
> form, but instead of sending off the location name on submittal, I'd 
> like to send an associated location ID, since I'm working with a 
> database.  I was wondering if I can set up a form element with a name 
> and without a type on selection of a given dropdown option.  To 
> elaborate:
>  
> Let's say I have a dropdown list of the following cities:
>  
> New York
> Los Angeles
> Boston
>  
> And each of these cities has associated with it a location ID, like:
> New York - 17
> Los Angeles - 13
> Boston - 6
>  
> I'd like a way to list the cities but send the ID's.  Could I do 
> something within the <option> tag like onselect="this.form.city_ID=17" 
> for New York?  If yes, could I just do it like that or would I

This sounds like the thing to do.  Since there is only 1 selection at a 
time you shouldn't have to worry with anything but updating the hidden 
field with the id.  The one thing I might add is to set up the dropdown 
with a blank element as the first row so the onselect event will fire 
and update the hidden.  Otherwise, if you have  an element that shows 
up in the dropdown as the first element you probably want to set the 
hidden in the onLoad event to the first item in the dropdown.

HTH,

Robert Pollard

> need to declare the form element city_ID as a hidden variable or 
> something along those lines?  If not, does anyone have any ideas?  I 
> hope my javascript idea is understandable, I'm just turning to this 
> language in order to move along a project that's primarily in PHP.
>  
> Thanks,
>  
> David.
<image.tiff>
>
>
>
> The information contained in this communication may be confidential, is
> intended only for the use of the recipient(s) named above, and may be
> legally privileged.  You are hereby notified that any dissemination,
> distribution or copying of this communication and any of its contents 
> or
> attachments is strictly prohibited.  If you have received this
> communication in error, please notify us immediately by replying to 
> this
> message and please delete this message from all computers and servers.
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2646 bytes
Desc: not available
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20031009/6bfa8e49/attachment.bin>


More information about the Javascript mailing list