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

Retrieving multiple values from a Select Box

Status
Not open for further replies.

dkn

Programmer
Oct 11, 2000
60
US
Hi,

I have a list of items that I want my users to be able to select multiple values from. I've set the list up no probs, and use the Multiple attribute to allow mulitple selections.

The question I have is how do I retrieve these values?.

Using the get method I get a querystring that looks like this in the address bar, where lstOutpost is the name of the Select box.


If I do a Outpost = request.querystring("lstOutpost") what value will be assigned to my variable Outpost?

Do I need to manually parse the querystring?...

How would it work using the Post method?

Any help greatly appreciated.

David
 
an array of values will get passed to the variable

use the ubound function to iterate through the array and assign a value to another variable to do stuff with it

the easy way to see this is to use the GET method of passing data, see what the address bar shows when you hit the submit button.... Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Thanks... I was kind of hoping it would be that simple

David :eek:)
 
I've had a go at implementing this, without much success.

After I've ran the initial page and selected multiple values from my select box I get something like this in the querystring


To retrieve the values I did

Outpost = request.querystring("lstOutpost")

If I output the value of Outpost I get

EFFPLT, GAUGE

i.e. a comma delimited string. not an array.

I cannot use the Ubound function to determine the number of items, as it doesn't recognise Outpost as an array.

I could probably dimension an array, use some string functions to chop up the delimited string, and assign these as elements of the array, the redimension the array to remove the empty elements. However this seems a bit convoluted.

Am I missing something here?, does anyone have a simpler way of doing this.

Thanks

David :eek:)
 
why not just split the data by comma to get the individual values...

and does the select box use a '[]' to idicate array? this should be part of the name

<select name=&quot;OUTPUT[]&quot; MULTIPLE>

Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
first use VBScript's &quot;split&quot; function to split your comma delimited string into an array, and THEN you can use the UBound function and iterate through the selected values...


Dim arrValues, j
arrValues = split(Request.QueryString(&quot;lstOutpost&quot;), &quot;,&quot;)
For j = 0 to UBound(arrValues)
'process your value here, e.g.,
'Response.Write arrValues(j)
Next

good luck!
 
Thanks..

I managed to split the string using string functions, but both solutions above look far easier.

Thanks for your help

David :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top