#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    15
    Rep Power
    0

    javascript drop down box


    I need a drop down script that allows a user to select a name from the drop down menu and depending on which name he selects it will display text on the same page.

    I have a example here:

    http://smart-hosting.com/game_ded.php

    the drop down is under "server location"

    I looked everywhere and all I can find is crappy code, nothing real easy to use.

    Brad
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Melbourne, Australia
    Posts
    212
    Rep Power
    12
    Here's the code being used on the sample site:

    Code:
    <form name="doublecombo">
    <p align="center"><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
    <option>Phoenix</option>
    <option>Dallas</option>
    <option>San Francisco</option>
    <option>New York</option>
    </select><br>
    <br>
    <select name="stage2" size="1">
    <option>69.50.192.12</option>
    <option>69.50.192.13</option>
    </select></p>
    
    <script>
    <!--
    
    /*
    Double Combo Script Credit
    By JavaScript Kit (www.javascriptkit.com)
    Over 200+ free JavaScripts here!
    */
    
    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()
    
    group[0][0]=new Option("69.50.192.12","")
    group[0][1]=new Option("69.50.192.13","")
    
    group[1][0]=new Option("69.56.129.34","")
    group[1][1]=new Option("216.127.94.122","")
    
    group[2][0]=new Option("65.60.32.220","")
    
    group[3][0]=new Option("65.125.224.51","")
    
    
    var temp=document.doublecombo.stage2
    
    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<group[x].length;i++){
    temp.options[i]=new Option(group[x][i].text,group[x][i].value)
    }
    temp.options[0].selected=true
    }
    
    function go(){
    location=temp.options[temp.selectedIndex].value
    }
    //-->
    </script>
    
    </form>
    Is this what you were looking for?
    How can I soar like an eagle when
    I'm flying with turkey's?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    15
    Rep Power
    0
    ya thats it,
    I found that code last nite and added it.

    Thanks,
    Brad
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    328
    Rep Power
    14
    This script defines an Option, but no value. I need to set a value, because I want to use this in a submit form. But how?

    Any help appreciated.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    328
    Rep Power
    14
    found it...

    PHP Code:
    group[0][0]=new Option("juni","6")
    //is the same as:
    //<option value='6'>juni</option> 

IMN logo majestic logo threadwatch logo seochat tools logo