Hi I would like to get all the values in a listbox. Here is the reason. I have 3 list boxes say A,B,C when I click on an Item in A it populates B with values and I select values from B and add it to C which removes it from B so no duplicates can be added to C.
I may still get data in B that I have already added to C. SO I need to get all the values in C so I can screen data from the server before I add them to B when I click between Items in A.
Also the items in B(A) are not uni开发者_开发知识库que i.e. let say I click on an Item in A say A1 and B gets populated with data lets call this data B1(its a set) if I click on another item in A say A2 and B gets populated with data say B2 the intersection of B1 and B2 is not always empty (there could exist an item in B1 and B2).
I know this is a bit complicated explanation but can you just tell me how to get all the values of a listbox or how to iterate through them
To loop through list options with jQuery and store in an array use the following:
//Array to hold original subTypes
var _SubTypes = new Array();
//Function to Store Initial List of Sub Types
function StoreSubTypes()
{
$("#comp_subtype option").each(
function(index, option)
{
//Store the option
_SubTypes[index] = option;
}
);
}
You could have an array for each list and call the code abouve but with a parameter for the list to store, and the array to store it in
精彩评论