473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Listbox in Javascript

malav123
217 100+
HI,
I am using two listboxes in asp.net and i am using javascript for moving items from one list box to another but when i am trying to move all items from one listbox to another listbox then not all the items moves from one listbox to another but only some items removes and moves so can you give me suggestion for my problem... my code is given below....
Expand|Select|Wrap|Line Numbers
  1.  if(id=="ctl00_ContentPlaceHolder1_TabAddCompany_TabPanel1_btnnextall")
  2.     {        
  3.         var i = 0;        
  4.         for (i = 0; i <= lstavailablestate.length - 1; i++)
  5.         {
  6.             var newOption = new Option(); // Create a new instance of ListItem
  7.             newOption.text = lstavailablestate.options[i].text;
  8.             newOption.value = lstavailablestate.options[i].value;
  9.  
  10.             lstassociatedstate.options[i] = newOption; //Append the item in Target
  11.             hid = hid + lstavailablestate.options[i].value + ",";
  12.             lstavailablestate.remove(i);  //Remove the item from Source                                        
  13.         }        
  14.  
  15.      }
  16.  
awaiting for reply...
thanks in advance......
Mar 18 '08 #1
2 1226
Frinavale
9,735 Expert Mod 8TB
HI,
I am using two listboxes in asp.net and i am using javascript for moving items from one list box to another but when i am trying to move all items from one listbox to another listbox then not all the items moves from one listbox to another but only some items removes and moves so can you give me suggestion for my problem... my code is given below....
Expand|Select|Wrap|Line Numbers
  1.  if(id=="ctl00_ContentPlaceHolder1_TabAddCompany_TabPanel1_btnnextall")
  2.     {        
  3.         var i = 0;        
  4.         for (i = 0; i <= lstavailablestate.length - 1; i++)
  5.         {
  6.             var newOption = new Option(); // Create a new instance of ListItem
  7.             newOption.text = lstavailablestate.options[i].text;
  8.             newOption.value = lstavailablestate.options[i].value;
  9.  
  10.             lstassociatedstate.options[i] = newOption; //Append the item in Target
  11.             hid = hid + lstavailablestate.options[i].value + ",";
  12.             lstavailablestate.remove(i);  //Remove the item from Source                                        
  13.         }        
  14.  
  15.      }
  16.  
awaiting for reply...
thanks in advance......
Do you know in what cases the values are "sometimes not moved" correctly?
Is it when it is the first item in the list?
Is it when it is the last item in the list?
Is it in the middle?

There should be some pattern as to why this is not working "sometimes".

-Frinny
Mar 18 '08 #2
malav123
217 100+
thanks for reply...
and i got solution of my problem....
i made two seprate loop then it is working now properly...
again thanks for response.....
Mar 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
1
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't...
4
by: Bob P. | last post by:
Hello, I have a page with: * two side-by-side asp:listboxes and two arrow asp:buttons allowing users to add/remove email addresses between them -- very much like Outlook, where you have the...
0
by: deepak | last post by:
Hi all, i m transefering values from one listbox to another listbox using javascript(both are html controls), the first listbox is populating with database at page_load time and the second listbox...
6
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I...
4
by: collie | last post by:
HI, I need to populate 2 listboxes from a db. When the page loads then the first listbox needs to be populated and based on selection from that listbox the second listbox needs to be populated...
4
by: Jeff | last post by:
....still new at this. ...hopefully a simple question Is there some practical way of altering the function of a keypress in Visual Web.net 2005 using VB without causing a postback on each...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
7
by: mikeh3275 | last post by:
I'm creating a .net program that uploads images to the FTP server. A blank listbox is populated dynamically on the client side from the value of the html input file widget. There is also a...
15
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.