Below is an html extract and a java script function.
The first box on the page allows you to select a country based on option values, once selected a javascript function runs which drills into an array and picks up all the resorts in that country. Fine.
When an option from the resorts box is selected a similar event should happen which picks up the sub resorts from another array based on resort selection. This is not happening. It doesn't seem to pass the resort value to the js function.
An example which should work is Spain, Benidorm.
Any help appreciated, mail to robert.beech@ants.co.uk
Thanks
Html:
<script language="JavaScript1.1" src="options-change.js"></script>
<html>
<head>
<title>Meet on holiday - Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- link to popups script -->
<script language="JavaScript" src="scripts/popups.js">
// no text required here - activated from links on page
</script>
<script language="JavaScript">
var resortArray = new Array();resortArray[0] = new Array ('Andorra','Arinsal-Pal');
resortArray[1] = new Array ('Andorra','Pas de la Casa');
resortArray[2] = new Array ('Andorra','Soldeu El Tarter');
resortArray[3] = new Array ('Australia','Sydney');
resortArray[4] = new Array ('Austria','Kitzbuhel');
resortArray[5] = new Array ('Austria','Niederau');
resortArray[6] = new Array ('Austria','Saalbach');
resortArray[7] = new Array ('Austria','Salzburg');
resortArray[8] = new Array ('Austria','Soll');
resortArray[9] = new Array ('Austria','Vienna');
resortArray[10] = new Array ('Austria','Zell Am See');
resortArray[11] = new Array ('Bahamas','Nassau');
resortArray[12] = new Array ('Balearic Islands','Formentera');
resortArray[13] = new Array ('Balearic Islands','Ibiza');
resortArray[14] = new Array ('Balearic Islands','Majorca');
resortArray[15] = new Array ('Balearic Islands','Menorca');
resortArray[16] = new Array ('Belgium','Brussels');
resortArray[17] = new Array ('Bermuda','Hamilton');
resortArray[18] = new Array ('Brazil','Costa do Sauipe');
resortArray[19] = new Array ('Brazil','Rio de Janeiro');
resortArray[20] = new Array ('Bulgaria','Albena');
resortArray[21] = new Array ('Bulgaria','Golden Sands');
resortArray[22] = new Array ('Bulgaria','Nessebur');
resortArray[23] = new Array ('Bulgaria','St Konstantin');
resortArray[24] = new Array ('Spain','Benidorm');
resortArray[25] = new Array ('Spain','Costa Blanca');
resortArray[26] = new Array ('Spain','Costa Brava');
resortArray[27] = new Array ('Spain','Costa del Sol');
resortArray[28] = new Array ('Spain','Costa Dorada');
resortArray[29] = new Array ('Spain','Madeira');
resortArray[30] = new Array ('Spain','Madrid');
resortArray[31] = new Array ('Spain','Seville');
</script>
<script language="JavaScript">
var subresortArray = new Array();subresortArray[0] = new Array ('Benidorm','Resort1');
subresortArray[1] = new Array ('Costa Dorada','Resort2');
</script>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body bgcolor="#9966cc" text="#000000" leftmargin="0" topmargin="0" >
<div align="center">
<table width="730" border="0" cellspacing="0" cellpadding="0" align="center" height="500">
<tr>
<td width="20" height="20" background="images/border-tl.gif"> </td>
<td background="images/border-t.gif" height="20"> </td>
<td width="18" height="20" background="images/border-tr.gif"> </td>
</tr>
<tr>
<td background="images/border-l.gif" width="20"> </td>
<td bgcolor="#FFFFFF" valign="top">
<table width="680" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="3">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top">
<p> </p>
<table width="350" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td background="images/searchbox-l.gif"> </td>
<td bgcolor="#ccccff" valign="middle"><table width="290" border="0" cellspacing="0"
cellpadding="0" align="center">
<form name="addholidayform" method="post">
<tr>
<td><p align="center">
<select id="nnCountry"
onChange="ChangeResortOptions('document.addholidayform.nnCountry',
'document.addholidayform.nnResort','resortArray');"
name="nnCountry">
<option value="novalue" selected>
Select a country...</option>
<option value='Andorra'>Andorra</option><option value='Australia'>Australia</option><option value='Austria'>Austria</option><option value='Bahamas'>Bahamas</option><option value='Balearic Islands'>Balearic Islands</option><option value='Belgium'>Belgium</option><option value='Bermuda'>Bermuda</option><option value='Brazil'>Brazil</option><option value='Bulgaria'>Bulgaria</option><option value='Canada'>Canada</option><option value='Canary Islands'>Canary Islands</option><option value='Channel Islands'>Channel Islands</option><option value='China'>China</option><option value='Costa Rica'>Costa Rica</option><option value='Croatia'>Croatia</option><option value='Cyprus'>Cyprus</option><option value='Czech Republic'>Czech Republic</option><option value='Denmark'>Denmark</option><option value='Egypt'>Egypt</option><option value='England'>England</option><option value='Estonia'>Estonia</option><option value='Finland'>Finland</option><option value='France'>France</option><option value='Germany'>Germany</option><option value='Gibraltar'>Gibraltar</option><option value='Greece'>Greece</option><option value='Hungary'>Hungary</option><option value='Iceland'>Iceland</option><option value='India'>India</option><option value='Ireland'>Ireland</option><option value='Israel'>Israel</option><option value='Italy'>Italy</option><option value='Jamaica'>Jamaica</option><option value='Japan'>Japan</option><option value='Kenya'>Kenya</option><option value='Korea'>Korea</option><option value='Latvia'>Latvia</option><option value='Lithuania'>Lithuania</option><option value='Malta'>Malta</option><option value='Mexico'>Mexico</option><option value='Morocco'>Morocco</option><option value='Netherlands'>Netherlands</option><option value='New Zealand'>New Zealand</option><option value='Nigeria'>Nigeria</option><option value='Norway'>Norway</option><option value='Poland'>Poland</option><option value='Portugal'>Portugal</option><option value='Puerta Rico'>Puerta Rico</option><option value='Romania'>Romania</option><option value='Russia'>Russia</option><option value='Scotland'>Scotland</option><option value='South Africa'>South Africa</option><option value='Spain'>Spain</option><option value='Sweden'>Sweden</option><option value='Switzerland'>Switzerland</option><option value='Thailand'>Thailand</option><option value='Tunisia'>Tunisia</option><option value='Turkey'>Turkey</option><option value='Venezuela'>Venezuela</option><option value='Wales'>Wales</option><option value='Yugoslavia'>Yugoslavia</option></select></p></td>
</tr>
<tr>
<td><p align="center">
<select id="nnResort"
onChange="ChangeSubResortOptions('document.addholidayform.nnResort',
'document.addholidayform.SubResort','subresortArray');"
name="nnResort">
<option value="novalue" selected>
Select a resort...</option>
</select></p></td>
</tr>
<tr>
<td><p align="center">
<select name="SubResort" id="SubResort" style="visibility:hidden">
<option value="novalue" selected>
Select a town/sub resort...</option>
</select></p></td>
</tr>
</form>
</table> </td>
<td background="images/searchbox-r.gif"> </td>
</tr>
</table>
<p> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td background="images/border-r.gif" width="18"> </td>
</tr>
</table>
<p align="center">
</div></body>
</html>
Javascript files (options-change.js)
function ChangeResortOptions(Country,Resort,CountryResort)
{
var arrLen = eval(CountryResort + ".length"
var strKey1 = trim_string(eval(Country + ".options[" + Country + ".selectedIndex].value");
eval(Resort + ".options.length = 0"
eval(Resort + ".options[0] = new Option('Select a resort...','?')"
var listLen = 1;
for (var i=0; i < arrLen; i++)
{
if (eval(CountryResort + "[0]" == trim_string(strKey1))
{
eval(Resort + ".options[listLen] = new Option(" + CountryResort + "[1])"
listLen = listLen + 1;
}
}
eval(Resort + ".options[0].selected = true"
if (document.layers)
{
history.go(0);
}
}
function ChangeSubResortOptions(Resort,SubResort,ResortSubResort)
{
var arrLen = eval(ResortSubResort + ".length"
var strKey1 = trim_string(eval(Resort + ".options[" + Resort + ".selectedIndex].value");
eval(SubResort + ".options.length = 0"
eval(SubResort + ".options[0] = new Option('Select a town/sub resort...','?')"
var listLen = 1;
for (var i=0; i < arrLen; i++)
{
if (eval(ResortSubResort + "[0]" == trim_string(strKey1))
{
eval(SubResort + ".options[listLen] = new Option(" + ResortSubResort + "[1])"
listLen = listLen + 1;
}
}
eval(SubResort + ".options[0].selected = true"
if (document.layers)
{
history.go(0);
}
if (listLen > 1)
{
document.addholidayform.SubResort.style.visibility = 'visible';
}
}
function ChangeSubResortOptionsDS(Resort,SubResort,ResortSubResort)
{
var arrLen = eval(ResortSubResort + ".length"
var strKey1 = trim_string(eval(Resort + ".options[" + Resort + ".selectedIndex].value");
eval(SubResort + ".options.length = 0"
eval(SubResort + ".options[0] = new Option('Select a town/sub resort...','?')"
var listLen = 1;
for (var i=0; i < arrLen; i++)
{
// if (eval(ResortSubResort + "[0]" == trim_string(strKey1))
// {
eval(SubResort + ".options[listLen] = new Option(" + ResortSubResort + "[1])"
listLen = listLen + 1;
// }
}
eval(SubResort + ".options[0].selected = true"
if (document.layers)
{
history.go(0);
}
//window.alert(SubResort);
// if (listLen > 1)
// {
document.detailedsearchform.SubResort.style.visibility = 'visible';
// }
}
function f_trimmer(thisstring)
{
while(thisstring.charAt(0)==" "
{
thisstring=thisstring.substring(1,thisstring.length)
}
thisstring=r_trimmer(thisstring)
return thisstring
}
function r_trimmer(thisstring)
{
while(thisstring.charAt(thisstring.length-1)==" "
{
thisstring=thisstring.substring(0,(thisstring.length-1))
}
return thisstring
}
function trim_string(thisstring)
{
return f_trimmer(thisstring)
}
function Unhide_Box(box_name)
{
eval(box_name + "= 'visible'"
}
The first box on the page allows you to select a country based on option values, once selected a javascript function runs which drills into an array and picks up all the resorts in that country. Fine.
When an option from the resorts box is selected a similar event should happen which picks up the sub resorts from another array based on resort selection. This is not happening. It doesn't seem to pass the resort value to the js function.
An example which should work is Spain, Benidorm.
Any help appreciated, mail to robert.beech@ants.co.uk
Thanks
Html:
<script language="JavaScript1.1" src="options-change.js"></script>
<html>
<head>
<title>Meet on holiday - Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- link to popups script -->
<script language="JavaScript" src="scripts/popups.js">
// no text required here - activated from links on page
</script>
<script language="JavaScript">
var resortArray = new Array();resortArray[0] = new Array ('Andorra','Arinsal-Pal');
resortArray[1] = new Array ('Andorra','Pas de la Casa');
resortArray[2] = new Array ('Andorra','Soldeu El Tarter');
resortArray[3] = new Array ('Australia','Sydney');
resortArray[4] = new Array ('Austria','Kitzbuhel');
resortArray[5] = new Array ('Austria','Niederau');
resortArray[6] = new Array ('Austria','Saalbach');
resortArray[7] = new Array ('Austria','Salzburg');
resortArray[8] = new Array ('Austria','Soll');
resortArray[9] = new Array ('Austria','Vienna');
resortArray[10] = new Array ('Austria','Zell Am See');
resortArray[11] = new Array ('Bahamas','Nassau');
resortArray[12] = new Array ('Balearic Islands','Formentera');
resortArray[13] = new Array ('Balearic Islands','Ibiza');
resortArray[14] = new Array ('Balearic Islands','Majorca');
resortArray[15] = new Array ('Balearic Islands','Menorca');
resortArray[16] = new Array ('Belgium','Brussels');
resortArray[17] = new Array ('Bermuda','Hamilton');
resortArray[18] = new Array ('Brazil','Costa do Sauipe');
resortArray[19] = new Array ('Brazil','Rio de Janeiro');
resortArray[20] = new Array ('Bulgaria','Albena');
resortArray[21] = new Array ('Bulgaria','Golden Sands');
resortArray[22] = new Array ('Bulgaria','Nessebur');
resortArray[23] = new Array ('Bulgaria','St Konstantin');
resortArray[24] = new Array ('Spain','Benidorm');
resortArray[25] = new Array ('Spain','Costa Blanca');
resortArray[26] = new Array ('Spain','Costa Brava');
resortArray[27] = new Array ('Spain','Costa del Sol');
resortArray[28] = new Array ('Spain','Costa Dorada');
resortArray[29] = new Array ('Spain','Madeira');
resortArray[30] = new Array ('Spain','Madrid');
resortArray[31] = new Array ('Spain','Seville');
</script>
<script language="JavaScript">
var subresortArray = new Array();subresortArray[0] = new Array ('Benidorm','Resort1');
subresortArray[1] = new Array ('Costa Dorada','Resort2');
</script>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body bgcolor="#9966cc" text="#000000" leftmargin="0" topmargin="0" >
<div align="center">
<table width="730" border="0" cellspacing="0" cellpadding="0" align="center" height="500">
<tr>
<td width="20" height="20" background="images/border-tl.gif"> </td>
<td background="images/border-t.gif" height="20"> </td>
<td width="18" height="20" background="images/border-tr.gif"> </td>
</tr>
<tr>
<td background="images/border-l.gif" width="20"> </td>
<td bgcolor="#FFFFFF" valign="top">
<table width="680" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="3">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top">
<p> </p>
<table width="350" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td background="images/searchbox-l.gif"> </td>
<td bgcolor="#ccccff" valign="middle"><table width="290" border="0" cellspacing="0"
cellpadding="0" align="center">
<form name="addholidayform" method="post">
<tr>
<td><p align="center">
<select id="nnCountry"
onChange="ChangeResortOptions('document.addholidayform.nnCountry',
'document.addholidayform.nnResort','resortArray');"
name="nnCountry">
<option value="novalue" selected>
Select a country...</option>
<option value='Andorra'>Andorra</option><option value='Australia'>Australia</option><option value='Austria'>Austria</option><option value='Bahamas'>Bahamas</option><option value='Balearic Islands'>Balearic Islands</option><option value='Belgium'>Belgium</option><option value='Bermuda'>Bermuda</option><option value='Brazil'>Brazil</option><option value='Bulgaria'>Bulgaria</option><option value='Canada'>Canada</option><option value='Canary Islands'>Canary Islands</option><option value='Channel Islands'>Channel Islands</option><option value='China'>China</option><option value='Costa Rica'>Costa Rica</option><option value='Croatia'>Croatia</option><option value='Cyprus'>Cyprus</option><option value='Czech Republic'>Czech Republic</option><option value='Denmark'>Denmark</option><option value='Egypt'>Egypt</option><option value='England'>England</option><option value='Estonia'>Estonia</option><option value='Finland'>Finland</option><option value='France'>France</option><option value='Germany'>Germany</option><option value='Gibraltar'>Gibraltar</option><option value='Greece'>Greece</option><option value='Hungary'>Hungary</option><option value='Iceland'>Iceland</option><option value='India'>India</option><option value='Ireland'>Ireland</option><option value='Israel'>Israel</option><option value='Italy'>Italy</option><option value='Jamaica'>Jamaica</option><option value='Japan'>Japan</option><option value='Kenya'>Kenya</option><option value='Korea'>Korea</option><option value='Latvia'>Latvia</option><option value='Lithuania'>Lithuania</option><option value='Malta'>Malta</option><option value='Mexico'>Mexico</option><option value='Morocco'>Morocco</option><option value='Netherlands'>Netherlands</option><option value='New Zealand'>New Zealand</option><option value='Nigeria'>Nigeria</option><option value='Norway'>Norway</option><option value='Poland'>Poland</option><option value='Portugal'>Portugal</option><option value='Puerta Rico'>Puerta Rico</option><option value='Romania'>Romania</option><option value='Russia'>Russia</option><option value='Scotland'>Scotland</option><option value='South Africa'>South Africa</option><option value='Spain'>Spain</option><option value='Sweden'>Sweden</option><option value='Switzerland'>Switzerland</option><option value='Thailand'>Thailand</option><option value='Tunisia'>Tunisia</option><option value='Turkey'>Turkey</option><option value='Venezuela'>Venezuela</option><option value='Wales'>Wales</option><option value='Yugoslavia'>Yugoslavia</option></select></p></td>
</tr>
<tr>
<td><p align="center">
<select id="nnResort"
onChange="ChangeSubResortOptions('document.addholidayform.nnResort',
'document.addholidayform.SubResort','subresortArray');"
name="nnResort">
<option value="novalue" selected>
Select a resort...</option>
</select></p></td>
</tr>
<tr>
<td><p align="center">
<select name="SubResort" id="SubResort" style="visibility:hidden">
<option value="novalue" selected>
Select a town/sub resort...</option>
</select></p></td>
</tr>
</form>
</table> </td>
<td background="images/searchbox-r.gif"> </td>
</tr>
</table>
<p> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td background="images/border-r.gif" width="18"> </td>
</tr>
</table>
<p align="center">
</div></body>
</html>
Javascript files (options-change.js)
function ChangeResortOptions(Country,Resort,CountryResort)
{
var arrLen = eval(CountryResort + ".length"
var strKey1 = trim_string(eval(Country + ".options[" + Country + ".selectedIndex].value");
eval(Resort + ".options.length = 0"
eval(Resort + ".options[0] = new Option('Select a resort...','?')"
var listLen = 1;
for (var i=0; i < arrLen; i++)
{
if (eval(CountryResort + "[0]" == trim_string(strKey1))
{
eval(Resort + ".options[listLen] = new Option(" + CountryResort + "[1])"
listLen = listLen + 1;
}
}
eval(Resort + ".options[0].selected = true"
if (document.layers)
{
history.go(0);
}
}
function ChangeSubResortOptions(Resort,SubResort,ResortSubResort)
{
var arrLen = eval(ResortSubResort + ".length"
var strKey1 = trim_string(eval(Resort + ".options[" + Resort + ".selectedIndex].value");
eval(SubResort + ".options.length = 0"
eval(SubResort + ".options[0] = new Option('Select a town/sub resort...','?')"
var listLen = 1;
for (var i=0; i < arrLen; i++)
{
if (eval(ResortSubResort + "[0]" == trim_string(strKey1))
{
eval(SubResort + ".options[listLen] = new Option(" + ResortSubResort + "[1])"
listLen = listLen + 1;
}
}
eval(SubResort + ".options[0].selected = true"
if (document.layers)
{
history.go(0);
}
if (listLen > 1)
{
document.addholidayform.SubResort.style.visibility = 'visible';
}
}
function ChangeSubResortOptionsDS(Resort,SubResort,ResortSubResort)
{
var arrLen = eval(ResortSubResort + ".length"
var strKey1 = trim_string(eval(Resort + ".options[" + Resort + ".selectedIndex].value");
eval(SubResort + ".options.length = 0"
eval(SubResort + ".options[0] = new Option('Select a town/sub resort...','?')"
var listLen = 1;
for (var i=0; i < arrLen; i++)
{
// if (eval(ResortSubResort + "[0]" == trim_string(strKey1))
// {
eval(SubResort + ".options[listLen] = new Option(" + ResortSubResort + "[1])"
listLen = listLen + 1;
// }
}
eval(SubResort + ".options[0].selected = true"
if (document.layers)
{
history.go(0);
}
//window.alert(SubResort);
// if (listLen > 1)
// {
document.detailedsearchform.SubResort.style.visibility = 'visible';
// }
}
function f_trimmer(thisstring)
{
while(thisstring.charAt(0)==" "
{
thisstring=thisstring.substring(1,thisstring.length)
}
thisstring=r_trimmer(thisstring)
return thisstring
}
function r_trimmer(thisstring)
{
while(thisstring.charAt(thisstring.length-1)==" "
{
thisstring=thisstring.substring(0,(thisstring.length-1))
}
return thisstring
}
function trim_string(thisstring)
{
return f_trimmer(thisstring)
}
function Unhide_Box(box_name)
{
eval(box_name + "= 'visible'"
}