Hi,
I came across this code for a dual select list and it works just fine.
The problem is that I'm trying to get the second select list (the one
on the right) to be on another, so that when you click the button to
pass the value to the other select list you would pass the value to
another frame. Being mostly and ASP programmer, I do not know how to
do it.
I'm posting the code below. Can anyone help me out, please?
Thanks in advance for any prompt reply.
PauloF
<script language="JavaScript"><!--
function deleteOption(object,index) {
object.options[index] = null;
}
function addOption(object,text,value) {
var defaultSelected = true;
var selected = true;
var optionName = new Option(text, value, defaultSelected, selected)
object.options[object.length] = optionName;
}
function copySelected(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
if (fromObject.options[i].selected)
addOption(toObject,fromObject.options[i].text,fromObject.options[i].valu
e);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
if (fromObject.options[i].selected)
deleteOption(fromObject,i);
}
}
function copyAll(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
addOption(toObject,fromObject.options[i].text,fromObject.options[i].valu
e);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
deleteOption(fromObject,i);
}
}
//--></script>
<form>
<table><tr><td>
<select name="select1" multiple size="7">
<option>zero
<option>one
<option>two
<option>three
<option>four
<option>five
<option>six
</select>
</td><td>
<input type="button" value=" > " onClick="if (document.images)
copySelected(this.form.select1,this.form.select2)">
<p>
<input type="button" value=" < " onClick="if (document.images)
copySelected(this.form.select2,this.form.select1)">
<p>
<input type="button" value=">>" onClick="if (document.images)
copyAll(this.form.select1,this.form.select2)">
<p>
<input type="button" value="<<" onClick="if (document.images)
copyAll(this.form.select2,this.form.select1)">
</td><td>
<select name="select2" multiple size="7">
</select>
</td></tr></table>
</form>