[thelist] Option Value change

7 sinz btcode at hotmail.com
Sat Jun 5 16:11:04 CDT 2004


Thank you Tim, that helps out a lot.

-peace

>From: apathetic <timbooker at gmail.com>
>Reply-To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
>To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
>Subject: Re: [thelist] Option Value change
>Date: Sat, 5 Jun 2004 13:09:25 +0100
>
>Let's say you have an array containing all of the options:
>
>var optionList = {
>     'USA' : '098039284',
>     .. etc ..
>}
>
>
>Then all you need is some code to rewrite the contents of your select box:
>
>functon rewriteOptions( selectBox ) {
>
>     selectBox.length = 0;
>
>     for( var opt in optionList ) {
>         selectBox.options[ selectBox.length ] = new Option( opt,
>optionList[ opt ] );
>     }
>}
>
>Call that when the page loads, passing a reference to the select box.
>
>Alternatively, you could simply use a document.write to generate the select 
>box:
>
><select>
>
><script type="text/javascript">
>
>     for( var opt in optionList ) {
>         document.write( '<option value="' + opt + '">' + optionList[
>opt ] + '</option>' );
>     }
>
></script>
>
></select>
>
>
>These are only code samples off the top of my head.  You might need to
>fiddle around slightly to get it working.
>
>Tim
>
>--
>http://www.apatheticgenius.com/
>--
>* * Please support the community that supports you.  * *
>http://evolt.org/help_support_evolt/
>
>For unsubscribe and other options, including the Tip Harvester
>and archives of thelist go to: http://lists.evolt.org
>Workers of the Web, evolt !

_________________________________________________________________
Get a Credit Card - 60 sec online response:   
http://ad.au.doubleclick.net/clk;8097459;9106288;b?http://www.anz.com/aus/promo/qantas5000ninemsn 
   [AU only]



More information about the thelist mailing list