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

Reading values from a ListBox

Status
Not open for further replies.

TudorSmith

Programmer
Jan 14, 2002
245
GB
Hi All

I have created two list boxes. From code found on the internet, I have manage to manipulate the values in List1 and transfer the selected values into List2.

What I need to do now is run a report based on the the captured values in List2...and that's why I need some assistance.

How do I iterate through the contents of List2 and build them into a string variable? Typically, I suspect it would look something like this:

Code:
While not end of list
  strValue = strValue & list2.item(i)
Wend

But I'm not sure

Thanks

Tudor

birklea ~©¿©~ <><
Dim objJedi as Jedi.Knight
Set objJedi[skyWalker].Aniken = FatherOf(useThe.Force(objJedi[skyWalker].luke))
 
how are the contents of the second (List2) element arranged? are they comma separated, space, pipe?

The simplest way is to split the List2 values on the separator and the use a for loop to move thru the array

say a comma is used to separate them
Code:
myList = request("list2")
Items = split(" ", myList)

for x = 0 to ubound(Items)-1
  strValue = strValue & items(x)
next


Bastien

Cat, the other other white meat
 
<select name="list1">
blah blahblah
</select>
<select name="list2" onchange="somescript">
blah blah
</select>
<script language="javascript>
function somescript()
{
//whatever needs doing reference the value from
var something = document.list2.selectname.options[document.list2.selectname.selectedIndex].value
}
//forewarning, numbers in form element names tend to make java unhappy
</script>
 
Thanks Both. I'm struggling with the first possibility.

DreXor...having stored the values in "something", how do I then use that variable, either on the same page or if passed to another page?

Thanks

Tudor

birklea ~©¿©~ <><
Dim objJedi as Jedi.Knight
Set objJedi[skyWalker].Aniken = FatherOf(useThe.Force(objJedi[skyWalker].luke))
 
have the somescript update a hidden field, then again, it's a list box, the value will pass across in a submit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top