Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > mutiple addition/remove in two listboxes

Reply
Thread Tools

mutiple addition/remove in two listboxes

 
 
deepak
Guest
Posts: n/a
 
      02-16-2005
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.sele ctedIndex);


// 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
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      02-16-2005
It sounds like you're trying to do something like this:

http://www.metabuilders.com/Tools/DualList.aspx

"deepak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.sele ctedIndex);
>
>
> // 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer between two listboxes ASPirant ASP .Net Web Controls 0 11-22-2005 09:35 PM
moving items between two listboxes ASPirant ASP .Net Web Controls 0 11-22-2005 08:07 AM
Tkinter: Selecting one item in each of two listboxes Jeffrey Barish Python 0 04-19-2004 10:16 PM
displaying a textboxes vs. listboxes depending on postback condition jason@cyberpine.com ASP .Net 1 11-05-2003 03:52 PM
listboxes......... bill yeager ASP .Net 3 08-11-2003 06:39 PM



Advertisments