...

View Full Version : Javascript drop down box navigation



donster
06-14-2004, 03:06 PM
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>

neofibril
06-15-2004, 10:39 AM
onchange="location.href = 'http://site.blah/directory/' + options[selectedIndex].value"

glenngv
06-15-2004, 11:08 AM
<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>

donster
06-15-2004, 12:14 PM
Script works great! Thank you for your time and quick response!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum