Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Drop Down Box Returning a price

    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>

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by Dennis626 View Post
    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.

    Quote Originally Posted by Dennis626 View Post
    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

    Code:
    var resortData = new Array();
    
    resortData['resort_1'] = [120,'resort_1.htm'];
    resortData['resort_2'] = [140,'resort_2.htm'];

  • #3
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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

  • #4
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by Dennis626 View Post
    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.

  • Users who have thanked bullant for this post:

    Dennis626 (04-03-2011)

  • #5
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •