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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS Combo box filtering? One box filters two

    Im making a web form, where the user will select which continent there on. That will then 'unhide' a drop box with a list of Country Codes found in that continent. At the same time, it will also 'unhide' a drop box with a list of Time Zones found in that continent.

    I can get it to load one drop box, but not two based off the first boxes selection.


    Honestly, I rather hand code 3 large arrays in JS over just using ajax and php/mysql. Reason is, iv already hand coded rather large arrays as it is, and the work put into those , i dont want to loose. Also I have all the information needed inside excel, and I can use functions to help print the array for me.

    Ex.
    North America
    Canada - United States - Mexico
    (us) Eastern - Central - Mountain - Pacific

  • #2
    Regular Coder
    Join Date
    Dec 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never mind I got something

    PHP Code:
    <a href="javascript:dubload(raycountry,'countrycodes',combo2,'timezones')">North America</a> | 
    <
    a href="javascript:dubload(ray2country,'countrycodes',combo4,'timezones')">Europe</a>
    <
    form name="combo">
    <
    select name="countrycodes">
    <
    option value="#">--loading--</option>
    </
    select><br /><br />
    <
    select name="timezones">
    <
    option value="#">--loading--</option>
    </
    select>
    </
    form>
    <
    script>
    <!--
    var 
    raycountry=new Array()
    raycountry[0]=new Option("United States","1")
    raycountry[1]=new Option("Canada","1")
    raycountry[2]=new Option("Mexico","1")
    raycountry[3]=new Option("Japan","15")
    raycountry[4]=new Option("China","55")
    var 
    combo2=new Array()
    combo2[0]=new Option("EST","utc")
    combo2[1]=new Option("CST","utc")
    combo2[2]=new Option("MST","utc")
    combo2[3]=new Option("PST","utc")
    var 
    ray2country=new Array()
    ray2country[0]=new Option("Canada","1")
    ray2country[1]=new Option("Mexico","1")
    ray2country[2]=new Option("United States","1")
    ray2country[3]=new Option("Japan","15")
    ray2country[4]=new Option("China","55")
    var 
    combo4=new Array()
    combo4[0]=new Option("CST","utc")
    combo4[1]=new Option("MST","utc")
    combo4[2]=new Option("EST","utc")
    combo4[3]=new Option("PST","utc")
    function 
    populate(x,box){
    var 
    cacheobj=document.getElementById(box)
    for (
    m=cacheobj.options.length-1;m>0;m--)
    cacheobj.options[m]=null
    selectedarray
    =eval(x)
    for (
    i=0;i<selectedarray.length;i++)
    cacheobj.options[i]=new Option(selectedarray[i].text,selectedarray[i].value)
    cacheobj.options[0].selected=true
    }
    function 
    dubload(x,box,t,bird) {
     
    populate(x,box)
     
    populate(t,bird)
    }
    //-->
    </script> 

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why dont this work in on the Mac


  •  

    Posting Permissions

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