Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Regarding Element adding via select box

    Today I have been trying to write a simple script. With selecting a certain "Option" via the Select Box, I'm trying to make the second Select Box correspond to the first. Sounds simple enough, though I'm finding some difficulties.

    Here is the basic:

    Code:
    <html>
    
    <head>
     <title>Index</title>
     <meta name="robots" content="noindex,nofollow" />
     <style type="text/css">
     </style>
    <head>
    
    <body>
     <script type="text/javascript">
    fuction country()
    {
    var country;
    var a=document.getElementById("us");
    var b=document.getElementById("can");
    var c=document.getElementById("misc");
    
    if (country==a) document.write("<select><option>New 
    
    Hampshire</option><option>Alabama</option<option>Alaska</option></select>");
    else if (country==b) document.write("<select><option>New 
    
    Brunswick</option><option>Alberta</option<option>Quebec</option></select>");
    else (country==c) document.write("<select><option>England</option><option>France</option<option>China</option></select>");
    }
     </script>
    
     <select>
      <option id="us" onselect="country()">United States</option>
      <option id="can" onselect="country()">Canada</option>
      <option id="misc" onselect="country()">Other</option>
     </select>
     
     <select>
     </select>
    </body>
    
    </html>
    Many thanks in advance for any suggestions correcting my errors.

  • #2
    Regular Coder Aradon's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    734
    Thanks
    0
    Thanked 20 Times in 19 Posts
    Java != javascript. Moved ^^
    "To iterate is human, to recurse divine." -L. Peter Deutsch

  • #3
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,802
    Thanks
    19
    Thanked 157 Times in 148 Posts
    I think I already answered this question here?: Regarding Element Adding via Select Options

    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •