473,508 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mutiple additon/remove in listboxex using javascript

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
0 1458

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2502
by: varadha | last post by:
Hi, My Application listening to a port of my machine and it response with data to the requesting system. This application is provided as a service in my machine. Now i am planning to have...
12
55527
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
3
4316
by: Hai Nguyen | last post by:
Hi all I was attempting to insert multiple row by using a loop into a database.A table has 2 primary keys and one regular field (PR) (PR) ID Project Ans 1 2 a 1 ...
0
1549
by: saravana | last post by:
I have to display the mutiple xml filename path in treeview control using c#. net some thing like this In treeview control....... ========= =C:\\a.xml=
6
3308
by: shanmugamit | last post by:
hi, var len=document.form.check.length flag=false; for(i=0;i<len;i++) { if(document.form.check.checked==true) { flag=true; break;
7
1695
by: shanmugamit | last post by:
hi, i using mutiple check box but i didn't get all value... as $res=mysql_query("select * from cie where des='Resource Pipeline Associate' order by name"); $j=0;...
9
2031
by: TechnoAtif | last post by:
<form name=frm action="" method="post"> <table> <tr><td><select name=combo> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <td><input type="text"...
2
2952
by: ravitunk | last post by:
hi..i have a datagridview in my windows application using C#......i want to select mutiple cells(by pressing shift key) or select mutiple columns or multiple rows.....if this happens then i should...
6
2158
by: dewraj | last post by:
Hi I am using windows applicaiton(.net) as front end, and I want to get mutiple tables in Dataset by executing a single stored procedure i.e. SP would return mutiple tables (record sets) with the...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.