...

View Full Version : Drop Down Box Returning a price



Dennis626
04-02-2011, 01:34 AM
Hello there

I am working on a non live Airport tranfer site
I have 3 interdependant drop down box.
Country -> Airport -> Resort
e.g USA, JFK , New York City

a-How can I attached a price to the route ?
b- How Can I linked the result of the search to a page of the site ?
Below is the code I used to create those list ?

Thanks for your time fellows.
Dennis
<html>
<head>

<script type="text/javascript">

var categories = [];categories["startList"] = ["Spain","France","Turkey","Greece"]

categories["Spain"] = ["Alicante","Barcelona","Malaga"];
categories["France"] = ["Paris","NIce","Lyon"];
categories["Turkey"] = ["Dalaman","Antalya","Bodrum"];
categories["Greece"] = ["Athens","Rhodes","Zante"];
categories["Alicante"] = ["Benidorm","El Abir","Finestra"];
categories["Barcelona"] = ["Lloret","Santa Suzanna","La Pineda"];
categories["Malaga"] = ["Puerto Banus","Fuengirola","Benalmadena"];
categories["Paris"] = ["Paris","Disneyland","Orly"];
categories["Nice"] = ["Nice","Monaco","Cannes"];
categories["Lyon"] = ["A","B","C"];
categories["Dalaman"] = ["A","B","C"];
categories["Antalya"] = ["d","e","f"];
categories["Bodrum"] = ["g","h","i"];
categories["Athens"] = ["1","2","3"];
categories["Rhodes"] = ["1a","2b","3c"];
categories["Zante"] = ["V","Y","A"];

var nLists = 3; // number of lists in the set

function fillSelect(currCat,currList){
var step = Number(currList.name.replace(/\D/g,""));
for (i=step; i<nLists+1; i++) {
document.forms[0]['List'+i].length = 1;
document.forms[0]['List'+i].selectedIndex = 0;
}
var nCat = categories[currCat];
for (each in nCat) {
var nOption = document.createElement('option');
var nData = document.createTextNode(nCat[each]);
nOption.setAttribute('value',nCat[each]);
nOption.appendChild(nData);
currList.appendChild(nOption);
}
}

function getValue(isValue) {
alert(isValue);
}

function init() {
fillSelect('startList',document.forms[0]['List1'])
}

navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);

</script>
</head>

<body>
<form action="">
<select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
<option selected>Select Country</option>
</select>
&nbsp;
<select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
<option selected>Select Airport</option>
</select>
&nbsp;
<select name='List3' onchange="getValue(this.value)">
<option selected >Select Resort</option>
</select>
</form>

</body>
</html>

bullant
04-02-2011, 01:59 AM
a-How can I attached a price to the route ?


Not sure what defines a route. Is it just the destination resort? If so, one option is to have an associative array with the resort name as key and the price as value.



b- How Can I linked the result of the search to a page of the site ?


I suppose it depends on what content is on the other page. If you have a page for each resort, one option is to have an associative array with the resort name as key and the url to the resort's web page as value. You could also combine this array with the one above.

Something like



var resortData = new Array();

resortData['resort_1'] = [120,'resort_1.htm'];
resortData['resort_2'] = [140,'resort_2.htm'];

Dennis626
04-02-2011, 02:10 AM
Hi Bullant

Thanks for your answer. I am a real novice in HTML with no knowledge except copy and paste and trying to decript the code

Happy to use your formula but where shall I paste it on my code ? Is the location important ?

For New york shall the code look like something like
resortData['New York'] = [120,'New York.htm']; ?

Thanks for your time Bullant

bullant
04-02-2011, 02:36 AM
Hi Bullant

Thanks for your answer. I am a real novice in HTML with no knowledge except copy and paste and trying to decript the code

Happy to use your formula but where shall I paste it on my code ? Is the location important ?

For New york shall the code look like something like
resortData['New York'] = [120,'New York.htm']; ?

Thanks for your time Bullant

no problem :)

I normally put my variable declarations at the top or near the top of the opening <script> or function. So in your case, you could put the resortData array just after your categories array declaration.

But you will need to add your own code to do something with the data in resortData otherwise the array will just sit there in your code gathering dust.

Dennis626
04-03-2011, 07:33 PM
Hi Bullant
I have been trying to play around all day long with this arrays code, looking on tutorial how to use that , really no success, I confess my total ignorance.
Is there anyway you could guide me on the code to use for let's say JFK AIrport to New York city if the price is 120 ?

Dennis



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum