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

    Question DropDown List which calls aspx page - Please Help

    hello everyone im coding a website at the moment using aspx and i have came to a snag. im trying to make a dropdown list which is populated by an array call my chaletDetails.aspx page - each item in the array will be directed to this page. ive diffled abit, but the more i do the more im afraid of breaking something lol. if someone could maybe look at the code and show me how this could be achieved id appriciate it very much.

    The code i have for my dropdown list is as follows... this is in divResorts.js

    var resorts = new Array("Adelboden", "Auron", "Oppdal", "Las Lenas", "La Pierre St Martin", "Val Ceneis", "Les Menuires", "Champex-Lac", "Puy St Vincent");

    function populateSelectList() {
    var mystring = document.getElementById('divResort').innerHTML
    mystring += "<h4>Our Resorts</h4><select name='resorts'>"

    mystring += "<option>Choose a Resort</option>"
    for (i = 0; i < resorts.length; i++) {
    mystring += "<option value='" + resorts[i] + "'>"
    mystring += resorts[i] + "</option>"
    }
    mystring += "</select>"
    mystring += "<h4>Our Chalets</h4>"
    document.getElementById('divResort').innerHTML = mystring
    }


    within the body i have this called as:

    <div id="divResort">

    <script type="text/javascript">populateSelectList();</script>

    </div>

  • #2
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would move your code to this. Problem is probably because the JS is inside the div you are trying to replace stuff inside.

    <div id="divResort"></div>
    <script>
    var resorts = new Array("Adelboden", "Auron", "Oppdal", "Las Lenas", "La Pierre St Martin", "Val Ceneis", "Les Menuires", "Champex-Lac", "Puy St Vincent");

    function populateSelectList() {
    var mystring = "<h4>Our Resorts</h4><select name='resorts'>";

    mystring += "<option>Choose a Resort</option>";
    for (i = 0; i < resorts.length; i++) {
    mystring += "<option value='" + resorts[i] + "'>";
    mystring += resorts[i] + "</option>";
    }
    mystring += "</select>";
    mystring += "<h4>Our Chalets</h4>";
    document.getElementById('divResort').innerHTML = mystring;
    }
    populateSelectList()

    </script>


  •  

    Posting Permissions

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