DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Pull Down Menu Next / Back Functionality
function selectNextBack(name,direction) {
var sel = (document.getElementById ? document.getElementById(name) : document.all[name]);
if(sel == null) { return false; }
var ops = sel.options.length;
var num = sel.selectedIndex;
if(ops > 0){
if(direction == "next"){
if (ops-num == 1){
sel.selectedIndex = 0;
} else {
sel.selectedIndex = num+1;
}
}else{
if (num == 0){
sel.selectedIndex = ops-1;
} else {
sel.selectedIndex = num-1;
}
}
}
}
EXAMPLE
<a href="javascript:void(0);" onclick="selectNextBack('itemid','back');">Back</a>
<select id="itemID" name="itemID">
<option value=""></option>
<option value="25">Item 1</option>
<option value="76">Item 2</option>
<option value="33" selected>Item 3</option>
<option value="48">Item 4</option>
</select>
<a href="javascript:void(0);" onclick="selectNextBack('itemid','next');">Next</a>




