In the below example we have a two list boxes where we can transfer one list box value to another list box. and vice verse. I found this useful when creating a distribution list where you have a set of people available to go into that list.
<html>
<head>
<script language="JavaScript">
<!--
function one2two() {
m1len = m1.length ;
for ( i=0; i<m1len ; i++){
if (m1.options[i].selected == true ) {
m2len = m2.length;
m2.options[m2len]= new Option(m1.options[i].text);
}
}
for ( i = (m1len -1); i>=0; i--){
if (m1.options[i].selected == true ) {
m1.options[i] = null;
}
}
}
function two2one() s{
m2len = m2.length ;
for ( i=0; i<m2len ; i++){
if (m2.options[i].selected == true ) {
m1len = m1.length;
m1.options[m1len]= new Option(m2.options[i].text);
}
}
for ( i=(m2len-1); i>=0; i--) {
if (m2.options[i].selected == true ) {
m2.options[i] = null;
}
}
}
//-->
</script>
</head>
<body>
form method="post" name="theForm">
<table align="center" bgcolor="white" border="1" cellpadding="10" cellspacing="0">
<tbody><tr><td align="center">
<select name="menu1" size="10" multiple="multiple">
<option>Menu Item 2</option>
<option>Menu Item 3</option>
<option>Menu Item 5</option>
</select><br>
<p align="center"><input onclick="one2two()" value=" >> " type="button"></p>
</td><td align="center">
<select name="menu2" size="10" multiple="multiple">
<option>Menu Item 6</option>
<option>Menu Item 4</option>
<option>Menu Item 1</option
</select><br>
<p align="center"><input onclick="two2one()" value=" << " type="button"></p>
</td></tr></tbody></table>
</form>
</body>
</html>
No comments:
Post a Comment