mutiple additon/remove in listboxex using javascript

G

Guest

i have set multiple selection property in bith listboxes(html control) to
true. i have taken 2 buttons(html control) say Button1,Button2.now i want to
add mutiple selected items to another listbox after clicking button1, and
similray remvoing the mutiple selected ite,s from, another after clicking
button2 ,, how can i do this ,, my script is given belo
..........................................................................................
<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':

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>

...............................................................................................
Private 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 Su
....................................................................................
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top