2 menus, 2nd changes upon 1st selection- HELP! DIDNT WORK AND HAS TO BE DONE TODAY!!
hey guys for balingo.com the template is basically completed but theres some javascript code i need. i have one text field and then two menus. they MUST ALL BE IN ONE FORM.
the first menu will contain a list of "all of UK" or a country. upon selection of the country, the second menu will change to have the counties of that country. it would be best that when "all of UK" is selected, there isnt a second menu and when a country is selected, it appears- but that isnt required.
can anyone help me out?
Last edited by geiger; Jul 12, 2001 at 16:59 .
SitePoint Enthusiast
i think that will work very nicely. i thank you greatfully =)
OOOOOOOHHH no.... i spent almost an hour editing that stupid script and then it didnt work! what did i do wrong? help!!
<form name="doublecombo">
<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option value="uk" selected>All of UK</option>
<option value="england">England</option>
<option value="scotland">Scotland</option>
<option value="northern_ireland">Northern Ireland</option>
<option value="wales">Wales</option>
</select>
<select name="stage2" size="1">
<option value="all_counties" selected>All Counties</option>
</select>
<input type="button" name="test" value="Go!"
onClick="go()">
<script>
<!--
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("All Counties","all_counties")
group[1][0]=new Option("All of England","all_of_england")
group[1][1]=new Option("Bedfordshire","bedfordshire")
group[1][2]=new Option("Berkshire","berkshire")
group[1][3]=new Option("Buckinghamshire","buckinghamshire")
group[1][4]=new Option("Cambridgeshire","cambridgeshire")
group[1][5]=new Option("Cheshire","chesire")
group[1][6]=new Option("Cornwall","cornwall")
group[1][7]=new Option("County Durham","county_durham")
group[1][8]=new Option("Cumbria","cumbria")
group[1][9]=new Option("Derbyshire","derbyshire")
group[1][10]=new Option("Devon","devon")
group[1][11]=new Option("Dorset","dorset")
group[1][12]=new Option("East Sussex","east_sussex")
group[1][13]=new Option("Essex","essex")
group[1][14]=new Option("Gloucestershire","gloucestershire")
group[1][15]=new Option("Hampshire","hampshire")
group[1][16]=new Option("Herefordshire","herefordshire")
group[1][17]=new Option("Isle of Man","isle_of_man")
group[1][18]=new Option("Isle of Wight","isle_of_wight")
group[1][19]=new Option("Kent","kent")
group[1][20]=new Option("Lancashire","lancashire")
group[1][21]=new Option("Leicestershire","leicestershire")
group[1][22]=new Option("Lincolnshire","lincolnshire")
group[1][23]=new Option("London","london")
group[1][24]=new Option("Norfolk","norfolk")
group[1][25]=new Option("Northamptonshire","northamptonshire")
group[1][26]=new Option("Northumberland","northumberland")
group[1][27]=new Option("Nottinghamshire","nottinghamshire")
group[1][28]=new Option("Oxfordshire","oxfordshire")
group[1][29]=new Option("Rutland","rutland")
group[1][30]=new Option("Shropshire","shropshire")
group[1][31]=new Option("Somerset","somerset")
group[1][32]=new Option("Staffordshire","staffordshire")
group[1][33]=new Option("Suffolk","suffolk")
group[1][34]=new Option("Surrey","surrey")
group[1][35]=new Option("Warwickshire","warwickshire")
group[1][36]=new Option("West Sussex","west_sussex")
group[1][37]=new Option("Wiltshire","wiltshire")
group[1][38]=new Option("Worcestershire","worcestershire")
group[1][39]=new Option("Yorkshire","yorkshire")
group[1][0]=new Option("All of Scotland","all_of_scotland")
group[1][1]=new Option("Aberdeen &","aberdeen_grampian")
group[1][2]=new Option(" Grampian","aberdeen_grampian")
group[1][3]=new Option("Angus & City","angus_city_of_dundee")
group[1][4]=new Option(" of Dundee","angus_city_of_dundee")
group[1][5]=new Option("Argyll, the Isles,","argyll_the_isles_loch_lomond_stirling_trossachs")
group[1][6]=new Option(" Loch Lomond","argyll_the_isles_loch_lomond_stirling_trossachs")
group[1][7]=new Option(" Stirling &","argyll_the_isles_loch_lomond_stirling_trossachs")
group[1][8]=new Option(" Trossachs,","argyll_the_isles_loch_lomond_stirling_trossachs")
group[1][9]=new Option("Ayrshire & Arran","ayrshire_arran")
group[1][10]=new Option("Dumfries &","dumfries_galloway")
group[1][11]=new Option(" Galloway","dumfries_galloway")
group[1][12]=new Option("Edinburgh &","edinburgh_lothians")
group[1][13]=new Option(" Lothians","edinburgh_lothians")
group[1][14]=new Option("Greater Glasgow","greater_glasgow_clyde_valley")
group[1][15]=new Option(" & Clyde Valley","greater_glasgow_clyde_valley")
group[1][16]=new Option("Highlands","highlands")
group[1][17]=new Option("Kingdom of Fife","kingdom_of_fife")
group[1][18]=new Option("Perthshire","perthshire")
group[1][19]=new Option("Scottish Borders","scottish_borders")
group[1][20]=new Option("Western Isles","western_isles")
group[2][0]=new Option("All of N Ireland","all_of_northern_ireland")
group[2][1]=new Option("Antrim","antrim")
group[2][2]=new Option("Armagh","armagh")
group[2][3]=new Option("Down","down")
group[2][4]=new Option("Fermanagh","fermanagh")
group[2][5]=new Option("Londonderry","londonderry")
group[2][6]=new Option("Tyrone","tyrone")
group[3][0]=new Option("All of Wales","all_of_wales")
group[3][1]=new Option("Anglesey","anglesey")
group[3][2]=new Option("Cardiff &","cardiff_glamorgan_coast")
group[3][3]=new Option(" Glamorgan Coast","cardiff_glamorgan_coast")
group[3][4]=new Option("Carmarthenshire","carmarthenshire")
group[3][5]=new Option("Ceredigion","ceredigion_cardigan_bay")
group[3][6]=new Option(" Cardigan Bay","ceredigion_cardigan_bay")
group[3][7]=new Option("Llandudno","llandudno_colwyn_bay_rhyl_prestatyn")
group[3][8]=new Option( Colwyn Bay, Rhyl,","llandudno_colwyn_bay_rhyl_prestatyn")
group[3][9]=new Option(" Prestatyn","llandudno_colwyn_bay_rhyl_prestatyn")
group[3][10]=new Option("Mid Wales Lakes","mid_wales_lakes_mountians")
group[3][11]=new Option(" & Mountains","mid_wales_lakes_mountians")
group[3][12]=new Option("North Wales","north_wales_borderlands")
group[3][13]=new Option(" Borderlands","north_wales_borderlands")
group[3][14]=new Option("Pembrokeshire","pembrokeshire")
group[3][15]=new Option("Snowdonia","snowdonia")
group[3][16]=new Option("South Wales","south_wales_valleys")
group[3][17]=new Option(" Valleys","south_wales_valleys")
group[3][18]=new Option("Swansea Bay","swansea_bay")
group[3][19]=new Option("Wye & Usk","wye_usk_valleys")
group[3][20]=new Option(" Valleys","wye_usk_valleys")
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>
okay i realized on the [1][1] part i accidentally put the first [number here] 1 twice. thats not the problem. it still doesnt work! help! i need it by tonight!
I looked at the code a few days ago and the only errors I found were with the array elements indexes (which you'd realised) and that the Colwyn Bay.. entry is missing an opening quote.
Fixing those and everything worked fine.
Sorry I didn't post geiger, but I figured you must have got it all sorted as you hadn't posted back.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks