mutiple addition/remove in two listboxes

D

deepak

i want to add and remove mutiple selected values in first list box(html
control) to another(html control) at the same time after clicking a
bttuonsay(Button1,html control) and remove mutiple selected text in another
list box after cliking another button(Button2,html control) ..
my script is given below
...........
<script language=javascript>
function doDetail(Action)
{
switch(Action)
{
case 'Add':
var lstFrom = document.getElementById("lstFrom");
var lstTo = document.getElementById("lstTo");
if(document.Form1.lstFrom.selectedIndex == -1)
{
alert('Please select atleast one record to Add');
return;

}
else
{
var o = document.createElement("option");
var selIndex = lstFrom.selectedIndex;
o.text = lstFrom.options[selIndex].text;
o.value = lstFrom.options[selIndex].value;
var i=0;
for (i = 0; i <=lstFrom.selectedIndex; i++)
{
alert(i);
}
document.getElementById("lstTo").add(o);
}
break;

case 'Remove':

//var lstFrom = document.getElementById("lstTo");
//var lstTo = document.getElementById("lstFrom");
if(document.Form1.lstTo.selectedIndex == -1)
{
alert('Please select atleast one record to Remove');
return;
}
else
{

var o = document.createElement("option");
var selIndex = lstTo.selectedIndex;
o.text = lstTo.options[selIndex].text;
o.value = lstTo.options[selIndex].value;
document.getElementById("lstTo").remove(lstTo.selectedIndex);


// document.getElementById("lstTo").remove(new Option
("o.text","o.value"));
document.getElementById("lstFrom").add(o);

}
break;

}
}
</script>
.........................................
rivate Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

Button1.Attributes("OnClick") = "javascript:doDetail(this.value);"
Button2.Attributes("OnClick") = "javascript:doDetail(this.value);"





If Page.IsPostBack = False Then
fnFillListBox()


End If
End Sub
.........................................

help me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top