View Full Version : Need help with list menus
usban
07-18-2002, 10:10 AM
I'm trying to build a apge in whichi appear two list/menus, one with a list of names and the other empty. I would like to be able to copy the name from one side to the other just by clicking a button.
It's like the way you personalize the buttons of the IE.
If you don't know, does anybody know the properties and methods of this elements (list/menu) ??
thank you.
:rolleyes:
neil.c
07-18-2002, 11:20 AM
does this do it? i made this for a similar purpose, and i've simplified it to the basics.
<HTML>
<HEAD>
<TITLE>combo swapper</TITLE>
<script language=javascript>
<!--
//script by neil clements.
function moveDown(){
var cbo1 = document.theForm.comboBox1
var cbo2 = document.theForm.comboBox2
if (cbo1.options.length > 0){
var itemToCopy = new Option(cbo1.options[cbo1.selectedIndex].text, cbo1.options[cbo1.selectedIndex].value)
cbo2.options[cbo2.options.length] = itemToCopy
cbo2.selectedIndex = cbo2.options.length - 1
cbo1.remove(cbo1.selectedIndex)
cbo1.selectedIndex = 0
}
}
function moveUp(){
var cbo1 = document.theForm.comboBox1
var cbo2 = document.theForm.comboBox2
if (cbo2.options.length > 0){
var itemToCopy = new Option(cbo2.options[cbo2.selectedIndex].text, cbo2.options[cbo2.selectedIndex].value)
cbo1.options[cbo1.options.length] = itemToCopy
cbo1.selectedIndex = cbo1.options.length - 1
cbo2.remove(cbo2.selectedIndex)
cbo2.selectedIndex = 0
}
}
//-->
</script>
</HEAD>
<BODY>
<form name="theForm">
<select name="comboBox1">
<option>choice1</option>
<option>choice2</option>
<option>choice3</option>
<option>choice4</option>
</select>
<br>
<input type=button value=" ^ " onclick="moveUp()">
<input type=button value=" v " onclick="moveDown()">
<br>
<select name="comboBox2">
</select>
</form>
</BODY>
</HTML>
any good?:thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.