...

View Full Version : JS Combo box filtering? One box filters two



glish_dreams
06-10-2008, 04:29 AM
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

glish_dreams
06-10-2008, 11:57 PM
Never mind I got something


<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>

glish_dreams
06-11-2008, 01:39 PM
Why dont this work in on the Mac :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum