By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,130 Members | 2,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,130 IT Pros & Developers. It's quick & easy.

mutiple additon/remove in listboxex using javascript

P: n/a
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.sele ctedIndex);
// 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
.................................................. ..................................
Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.