Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping <OPTION> Lists in a dynamically created List or Combo Box

Status
Not open for further replies.

Jorgandr

Programmer
May 10, 2002
58
0
0
US
I have a page that has a 2 list boxes and a combo box. The first list box is populated from a database with all the names of our associates. The other list box is empty as is the combo box. Here are the identifiers for each item:

List box #1
Available Users

List box #2
Selected users

Combo box #1
Manager

What happens is that I have a javascript coding that will allow a user to dynamically fill list box #2 and combo box #1 with the users selected in list box #1 after they hit the add >> button. Additionally it will remove those names from list box #1. However, I also have checks in place after submitting the form to make sure the user is entering in the right data. When the user does not input in something correctly, the values for all the list/combo boxes revert back to its original state. Is there any way I can keep the values that were selected for each object? Additionally, How do you then pull these values after they are populated so I can insert them into my database? Any help would be greatly appreciated. Thank you.
 
Have you tried using javascript to validate the data on the client side? If you can run your checks on the client side, the user would never leave the page if there was a problem with the data, thus the list boxes wouldn't be reset.

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
yeah i agree, personally what i've done in the past for instances like this is to make 2 combo boxes with substantial rows to them so they appear as text areas, click the line and press add, and using javascript add/remove the items from the second box, meanwhile on pageload, box 2 would be empty, it's only populated by box one.

if you wish to avoid this because of possible disabled javascript, it's fairly easy with submit value="add" and "remove" use this to check against, and build the boxes server side, and when done, push everything on over to box 3, or you can do it as each one is added/removed.

as for removing names from box one... how about not removing them immediately, what if you just "hide" them because they are in box two until the shuffle is confirmed and committed.

easiest way i can think of is make a group of the items built for list 2 and as you cycle list 1, if item from list 1 is in group 2, skip it, then after just make list 2 from group 2



[thumbsup2]DreX
aKa - Robert
 
hi, I'm trying to find a way or replicating Microsoft Accesse's "not in list" event for combo boxes on my add record ASP page.
The user will be entering CD details via the use of text fields and combo boxes. The form has an Artist combo box which is populated from my access database. The problem is that this does not always contain the required Artist and therefore the user needs to be able to enter a new Artist. I'm trying to avoid using pop up pages for this if at all possible. Any suggestions would be appreciated.

Also I have tried using an active x combo box but cannot work out how to populate it's list? any ideas?

Thanks in advance
Jacex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top