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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for loop with session variables

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
US
I have allowed multiple select on a listbox, and I want to pass all selected options to next page. I want to do this server side for reasons that are too complicated to get into.

The following code only gets the selected value if only one is selected.

for i=0 to lstSkills.getCount()
if lstSkills.selectedIndex > 0 then
dim skills, counter
skills = lstSkills.getText(lstSkills.selectedIndex)
session("Skills") = skills
counter = counter + 1
end if
next
session("numSelectedSkills") = counter

This loop loops through the listbox, looking for selected values, if selecetedIndex > 0, meaning it is selected, put in session variable. Now, I wanted to be able to make each one different so I gave it the value of i. I made this up. Obviously it doesn't work. What else should I do?

Then, using the counter, I have the following for loop on the next page, which only displays when only one was selected. Also, the session variable numSelectedSkills, which is supposed to be the number of times the if statement on the previous page was true, is always one more than the number of values in the listbox, so that's not working either. Probably a dumb logic mistake.

for i=0 to session("numSelectedSkills")
Response.Write session("Skills")
Response.Write session("numSelectedSkills")
next

Anyways, this seems pretty convoluted, and I would greatly appreciate some assistance in sorting it out.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top