Use JavaScript to move the list in two listboxes
Note:
1. ListBox is a server control, and list can be initialized on the server.
2. The button can be a server or a client control:
If it is a server-side control, you need to add an event to it during page initialization as follows:
Btn_updaddrel.attributes.add ("onclick", "javascript: add ();");
If it is a client control, specify event processing when declaring the control:
<Input type = "button" value = "add" onclick = "add ()">
3. event handling
<Script language = "JavaScript">
Function add ()
{
VaR objres = Document. getelementbyid ("lb_updrestitems ");
VaR objsel = Document. getelementbyid ("lb_updselitems ");
VaR customoptions;
For (VAR I = objres. Options. Length-1; I> = 0; I --)
{
If (objres. Options. Selected)
{
Customoptions = Document. createelement ("option ");
Customoptions. Text = objres. Options. text;
Customoptions. value = objres. Options. value;
Objsel. Add (customoptions, 0 );
Objres. Remove (I );
}
}
Return false;
}
</SCRIPT>