S
samomalo
Hi All
Been trying to figure this out all night but can't for the life of me.
I'm working on a links page for a website - I'm using a javascript
dropdown combo box to show the links, but I can't figure out how to
get it to open the links in a new window. Sure it's simple but I'm not
getting it!
Here's the code:
<form name="doublecombo">
<p><select name="example" size="1"
onChange="redirect(this.options.selectedIndex)">
<option selected="selected">Country</option>
<option>Argentina</option>
<option>Austria</option>
<option>Belgium</option>
<option>Bosnia and Herzegovina</option>
<option>Croatia</option>
<option>Czech Republic</option>
<option>Germany</option>
<option>Greece</option>
<option>Holland</option>
<option>Hungary</option>
<option>Ireland</option>
<option>Italy</option>
<option>Latvia</option>
<option>Poland</option>
<option>Serbia</option>
<option>Spain</option>
<option>United Kingdom</option>
</select>
<select name="stage2" size="1">
<option value="#">Select a country</option>
</select>
<input type="button" name="test" value="Go"
onClick="go()" >
</p>
<script>
<!--
/* COUNTRIES */
var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group=new Array()
/* Argentina */
group[1][0]=new Option("Buenos Aires - Hostel Colonial","http://
www.hostelcolonial.com.ar")
/* Austria */
group[2][0]=new Option("Salzburg & Vienna - Strawberry
Hostels","http://www.strawberryhostels.com")
group[2][1]=new Option("Vienna - Believe it or not Hostel","http://
www.believe-it-or-not-vienna.at")
/* Belgium */
group[3][0]=new Option("Antwerpen - New International Youth
Hotel","http://www.youthhotel.be")
/* Bosnia */
group[4][0]=new Option("Sarajevo - Harris youth
hostel","mailto:[email protected]")
/* Croatia */
group[5][0]=new Option("Hvar - Green Lizard","http://
www.greenlizard.hr")
group[5][1]=new Option("Zagreb - Hostel Fulir","http://www.fulir-
hostel.com")
group[5][2]=new Option("Zagreb - Ravnice youth hostel","http://
www.ravnice-youth-hostel.hr/")
group[5][3]=new Option("Dubrovnik - Dubrovnik backpackers
club","mailto:[email protected]")
/* Czech */
group[6][0]=new Option("Branik - Boathouse hostel Prague","http://
www.aa.cz/boathouse")
group[6][1]=new Option("Cesky Krumlov - Hostel 99","http://
www.hostel99.com")
group[6][2]=new Option("Prague - Czech-Inn","http://www.czech-
inn.com")
group[6][3]=new Option("Prague - U Melounu hostel","http://
www.hostelumelounu.cz")
group[6][4]=new Option("Prague - Rosemary Hostel","http://
www.praguecityhostel.cz")
group[6][5]=new Option("Prague - Hostel ELF","http://
www.hostelelf.cz")
group[6][6]=new Option("Prague - Sir Toby's Hostel Prague","http://
www.sirtobys.com")
/* Germany */
group[7][0]=new Option("Berlin - The Sunflower Hostel Berlin","http://
www.sunflower-hostel.de")
group[7][1]=new Option("Berlin - Meininger City Hostels &
Hotels","http://www.meininger-hostels.de")
group[7][2]=new Option("Berlin - The Circus","http://www.circus-
berlin.de")
group[7][3]=new Option("Berlin - BaxPax Hostel ","http://
www.baccos.de")
group[7][4]=new Option("Berlin - Heart of Gold Hostel","http://
www.heartofgold-hostel.de")
group[7][5]=new Option("Berlin - Globe Trotter Hostel","http://
www.globetrotterhostel.de")
group[7][6]=new Option("Berlin - Amstel House","www.amstelhouse.de")
group[7][7]=new Option("Cologne - Station Hostel for
Backpackers","http://www.hostel-cologne.de")
group[7][8]=new Option("Munich - 4 you","http://www.the4you.de")
group[7][9]=new Option("Munich - Easy Palace City Hostel","http://
www.easypalace.de")
/* Greece */
group[8][0]=new Option("Athens - Student and Travellers Inn","http://
www.hostelaphrodite.com")
group[8][1]=new Option("Corfu - Pink Palace","http://
www.thepinkpalace.com")
/* Holland */
group[9][0]=new Option("Amsterdam - The Flying Pig Hostels","http://
www.flyingpig.nl")
/* Hungary */
group[10][0]=new Option("Budapest - Hotel Rila","http://
www.hotelrila.com")
group[10][1]=new Option("Budapest - Back Pack Budapest","http://
www.backpackbudapest.hu")
group[10][2]=new Option("Budapest - Hostel Marco Polo","http://
www.marcopolohostel.com")
group[10][3]=new Option("Budapest - Broadway Hostel","http://
www.broadwayhostel.hu")
group[10][4]=new Option("Budapest - Vamhaz Hostel","http://
www.vamhaz.com")
group[10][5]=new Option("Budapest - Unity Hostel","http://
www.unityhostel.com")
group[10][6]=new Option("Budapest - Aventura Hostel","http://
www.aventurahostel.com")
group[10][7]=new Option("Budapest - August Hostel","http://
www.Augusthostel.com")
group[10][8]=new Option("Aboriginal Hostel","http://
www.aboriginalhostel.com ")
/* Ireland */
group[11][0]=new Option("Dublin - The Four Courts Hostel","http://
www.fourcourtshostel.com")
/* Italy */
group[12][0]=new Option("Brindisi - Youth Hostel Brindisi","http://
www.hostelcarpediem.it")
group[12][1]=new Option("Naples - Hostel & Hotel Bella Capri","http://
www.bellacapri.it")
group[12][2]=new Option("Positano - Hostel Brikette ","http://
www.brikette.com")
group[12][3]=new Option("Rimini - Sunflower Beach Backpackers
Hostel","http://www.sunflowerhostel.com")
group[12][4]=new Option("Rome - Alessandro Hostels","http://
Www.hostelsalessandro.com")
group[12][5]=new Option("Rome - Alessandro Palace Hostel in
Rome","http://www.hostelalessandropalace.com")
group[12][6]=new Option("Florence - Albergo Paola","http://
www.albergopaola.com")
group[12][7]=new Option("Naples - Bella Capri","http://
www.bellacapri.it")
/* Latvia */
group[13][0]=new Option("Riga - Riga Backpackers","http://www.riga-
backpackers.com")
/* Poland */
group[14][0]=new Option("Krakow - Ars Hostel","http://
Www.arshostel.pl")
group[14][1]=new Option("Krakow - Atlantis Hostel","http://
www.atlantishostel.pl")
group[14][2]=new Option("Krakow - The Stranger hostel","http://
www.thestrangerhostel.com")
/* Serbia */
group[15][0]=new Option("Belgrade - 6th floor Hostel","http://www.
6thfloorhostel.com")
group[15][1]=new Option("Belgrade - Star Hostel","http://www.star-
hostel.com")
/* Spain */
group[16][0]=new Option("Barcelona, Valencia - Home Hostels","http://
Www.likeathome.net")
/* UK */
group[17][0]=new Option("Oxford - Central Backpackers","http://
www.centralbackpackers.com")
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=new Option(group[x].text,group[x].value)
}
temp.options[0].selected=true
}
function go(){
location=temp.options[temp.selectedIndex].value
}
//-->
</script>
</form>
Any help much appreciated!
Sam
Been trying to figure this out all night but can't for the life of me.
I'm working on a links page for a website - I'm using a javascript
dropdown combo box to show the links, but I can't figure out how to
get it to open the links in a new window. Sure it's simple but I'm not
getting it!
Here's the code:
<form name="doublecombo">
<p><select name="example" size="1"
onChange="redirect(this.options.selectedIndex)">
<option selected="selected">Country</option>
<option>Argentina</option>
<option>Austria</option>
<option>Belgium</option>
<option>Bosnia and Herzegovina</option>
<option>Croatia</option>
<option>Czech Republic</option>
<option>Germany</option>
<option>Greece</option>
<option>Holland</option>
<option>Hungary</option>
<option>Ireland</option>
<option>Italy</option>
<option>Latvia</option>
<option>Poland</option>
<option>Serbia</option>
<option>Spain</option>
<option>United Kingdom</option>
</select>
<select name="stage2" size="1">
<option value="#">Select a country</option>
</select>
<input type="button" name="test" value="Go"
onClick="go()" >
</p>
<script>
<!--
/* COUNTRIES */
var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group=new Array()
/* Argentina */
group[1][0]=new Option("Buenos Aires - Hostel Colonial","http://
www.hostelcolonial.com.ar")
/* Austria */
group[2][0]=new Option("Salzburg & Vienna - Strawberry
Hostels","http://www.strawberryhostels.com")
group[2][1]=new Option("Vienna - Believe it or not Hostel","http://
www.believe-it-or-not-vienna.at")
/* Belgium */
group[3][0]=new Option("Antwerpen - New International Youth
Hotel","http://www.youthhotel.be")
/* Bosnia */
group[4][0]=new Option("Sarajevo - Harris youth
hostel","mailto:[email protected]")
/* Croatia */
group[5][0]=new Option("Hvar - Green Lizard","http://
www.greenlizard.hr")
group[5][1]=new Option("Zagreb - Hostel Fulir","http://www.fulir-
hostel.com")
group[5][2]=new Option("Zagreb - Ravnice youth hostel","http://
www.ravnice-youth-hostel.hr/")
group[5][3]=new Option("Dubrovnik - Dubrovnik backpackers
club","mailto:[email protected]")
/* Czech */
group[6][0]=new Option("Branik - Boathouse hostel Prague","http://
www.aa.cz/boathouse")
group[6][1]=new Option("Cesky Krumlov - Hostel 99","http://
www.hostel99.com")
group[6][2]=new Option("Prague - Czech-Inn","http://www.czech-
inn.com")
group[6][3]=new Option("Prague - U Melounu hostel","http://
www.hostelumelounu.cz")
group[6][4]=new Option("Prague - Rosemary Hostel","http://
www.praguecityhostel.cz")
group[6][5]=new Option("Prague - Hostel ELF","http://
www.hostelelf.cz")
group[6][6]=new Option("Prague - Sir Toby's Hostel Prague","http://
www.sirtobys.com")
/* Germany */
group[7][0]=new Option("Berlin - The Sunflower Hostel Berlin","http://
www.sunflower-hostel.de")
group[7][1]=new Option("Berlin - Meininger City Hostels &
Hotels","http://www.meininger-hostels.de")
group[7][2]=new Option("Berlin - The Circus","http://www.circus-
berlin.de")
group[7][3]=new Option("Berlin - BaxPax Hostel ","http://
www.baccos.de")
group[7][4]=new Option("Berlin - Heart of Gold Hostel","http://
www.heartofgold-hostel.de")
group[7][5]=new Option("Berlin - Globe Trotter Hostel","http://
www.globetrotterhostel.de")
group[7][6]=new Option("Berlin - Amstel House","www.amstelhouse.de")
group[7][7]=new Option("Cologne - Station Hostel for
Backpackers","http://www.hostel-cologne.de")
group[7][8]=new Option("Munich - 4 you","http://www.the4you.de")
group[7][9]=new Option("Munich - Easy Palace City Hostel","http://
www.easypalace.de")
/* Greece */
group[8][0]=new Option("Athens - Student and Travellers Inn","http://
www.hostelaphrodite.com")
group[8][1]=new Option("Corfu - Pink Palace","http://
www.thepinkpalace.com")
/* Holland */
group[9][0]=new Option("Amsterdam - The Flying Pig Hostels","http://
www.flyingpig.nl")
/* Hungary */
group[10][0]=new Option("Budapest - Hotel Rila","http://
www.hotelrila.com")
group[10][1]=new Option("Budapest - Back Pack Budapest","http://
www.backpackbudapest.hu")
group[10][2]=new Option("Budapest - Hostel Marco Polo","http://
www.marcopolohostel.com")
group[10][3]=new Option("Budapest - Broadway Hostel","http://
www.broadwayhostel.hu")
group[10][4]=new Option("Budapest - Vamhaz Hostel","http://
www.vamhaz.com")
group[10][5]=new Option("Budapest - Unity Hostel","http://
www.unityhostel.com")
group[10][6]=new Option("Budapest - Aventura Hostel","http://
www.aventurahostel.com")
group[10][7]=new Option("Budapest - August Hostel","http://
www.Augusthostel.com")
group[10][8]=new Option("Aboriginal Hostel","http://
www.aboriginalhostel.com ")
/* Ireland */
group[11][0]=new Option("Dublin - The Four Courts Hostel","http://
www.fourcourtshostel.com")
/* Italy */
group[12][0]=new Option("Brindisi - Youth Hostel Brindisi","http://
www.hostelcarpediem.it")
group[12][1]=new Option("Naples - Hostel & Hotel Bella Capri","http://
www.bellacapri.it")
group[12][2]=new Option("Positano - Hostel Brikette ","http://
www.brikette.com")
group[12][3]=new Option("Rimini - Sunflower Beach Backpackers
Hostel","http://www.sunflowerhostel.com")
group[12][4]=new Option("Rome - Alessandro Hostels","http://
Www.hostelsalessandro.com")
group[12][5]=new Option("Rome - Alessandro Palace Hostel in
Rome","http://www.hostelalessandropalace.com")
group[12][6]=new Option("Florence - Albergo Paola","http://
www.albergopaola.com")
group[12][7]=new Option("Naples - Bella Capri","http://
www.bellacapri.it")
/* Latvia */
group[13][0]=new Option("Riga - Riga Backpackers","http://www.riga-
backpackers.com")
/* Poland */
group[14][0]=new Option("Krakow - Ars Hostel","http://
Www.arshostel.pl")
group[14][1]=new Option("Krakow - Atlantis Hostel","http://
www.atlantishostel.pl")
group[14][2]=new Option("Krakow - The Stranger hostel","http://
www.thestrangerhostel.com")
/* Serbia */
group[15][0]=new Option("Belgrade - 6th floor Hostel","http://www.
6thfloorhostel.com")
group[15][1]=new Option("Belgrade - Star Hostel","http://www.star-
hostel.com")
/* Spain */
group[16][0]=new Option("Barcelona, Valencia - Home Hostels","http://
Www.likeathome.net")
/* UK */
group[17][0]=new Option("Oxford - Central Backpackers","http://
www.centralbackpackers.com")
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=new Option(group[x].text,group[x].value)
}
temp.options[0].selected=true
}
function go(){
location=temp.options[temp.selectedIndex].value
}
//-->
</script>
</form>
Any help much appreciated!
Sam