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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript drop down box navigation

    How can I create a navigational drop down box with different targets?


    See example below


    <form>
    <select size=4 style="width: 225px;" onChange="location.href=this.options[this.selectedIndex].value">
    <option value="../lessons/country/country.html">&nbsp;•&nbsp;Country licks</option>
    <option class="red" value="../forum/index.php">&nbsp;•&nbsp;Forum</option>
    <option value="../pdf/chord-chart.pdf">&nbsp;•&nbsp;PDF Chord Chart</option>
    <option class="red" value="simulation.html">&nbsp;•&nbsp;Chord Simulator</option>
    <option value="tab_lesson.html">&nbsp;•&nbsp;Tablature Explained</option>
    <option class="red" value="alternate-guitar-tunings.html">&nbsp;•&nbsp;Alternate Tunings</option>
    <option class="red" value="../serial/gibson.html">&nbsp;•&nbsp;Gibson Serial Number lookup</option>
    </select>
    </form>

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    onchange="location.href = 'http://site.blah/directory/' + options[selectedIndex].value"
    Last edited by neofibril; 06-15-2004 at 09:49 AM.

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Code:
    <script type="text/javascript">
    function doOpen(objSel){
      var optVal = objSel.options[objSel.selectedIndex].value;
      if (optVal!=''){
         var arrVal = optVal.split('|');
         var w = window.open(arrVal[1], arrVal[0]);
         w.focus();
      }
    }
    </script>
    ...
    <select size=4 style="width: 225px;" onChange="doOpen(this)">
    <option>Choose</option>
    <option value="_self|../lessons/country/country.html">&nbsp;•&nbsp;Country licks</option>
    <option value="_blank|../forum/index.php">&nbsp;•&nbsp;Forum</option>
    <option value="mywin|../pdf/chord-chart.pdf">&nbsp;•&nbsp;PDF Chord Chart</option>
    <option class="red" value="mywin|simulation.html">&nbsp;•&nbsp;Chord Simulator</option>
    <option value="mywin2|tab_lesson.html">&nbsp;•&nbsp;Tablature Explained</option>
    ...
    </select>

  • #4
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank You!

    Script works great! Thank you for your time and quick response!


  •  

    Posting Permissions

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