Reply
Splitting a multi-value, multiple select option box into a multidimensional array
Old 02-07-2007, 05:15 PM Splitting a multi-value, multiple select option box into a multidimensional array
Super Talker

Posts: 109
Okay, I have something that is really baffling me.

I'm writing a multiple select option box that is reading in from a database. I'm reading in three values, joining them together as a string.

<td><select name="Record" multiple="multiple" >
<% While Not rsAtlasTable.EOF %>

<option value="<%=Trim(rsAtlasTable("Company")) & ", " & Trim(rsAtlasTable("State")) %>"><%=TRIM(rsAtlasTable("Company")) & ", " & Trim(rsAtlasTable("State")) & ", " & Trim(rsAtlasTable("ID")) %></option>
<% rsAtlasTable.MoveNext
Wend %>

Now, I want to be able to split the values into a multiple dimension array. Basically, what I want is the ID number so I can build an SQL query to pull only those records.

If I do a SPLIT(), it creates a single array. Note I'm splitting for a comma deliminator. For example...

arrRecord = Split(Request.Form("Record"), ", ", -1, 1)

What this gives me is an array with value[0] = Company Name, value[1] = State and value[2] = ID.

This is a no go.

Now, I'm thinking after this post I can go back and "cheat" by just making the ID the first item in the multiple select box and then try not to pull on the other values, as I want only the ID field.

But, is there a way to create a multidimensional array in ASP with a multiple select?

Should I do this in JavaScript and just write to ASP variables (can you do that?)

Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 02-07-2007, 06:33 PM Re: Splitting a multi-value, multiple select option box into a multidimensional array
Learning Newbie's Avatar
Moderator

Posts: 5,199
Name: John Alexander
Why don't you just take everything after the last comma?
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 02-08-2007, 03:01 AM Re: Splitting a multi-value, multiple select option box into a multidimensional array
chrishirst's Avatar
Super Moderator

Posts: 13,626
Location: Blackpool. UK
yep you can use InstrRev or Right to locate it
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-08-2007, 01:40 PM Re: Splitting a multi-value, multiple select option box into a multidimensional array
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Donna: if all you want is the ID number from the select box, then why do you have the other values in the place of the ID number in the first place? It seems to me that you're making this way more complicated than you need to.

Do something like this:
Code:
Response.Write "<option value=""" & Trim(rsAtlasTable("ID")) & """>(Your option text here</option>" & vbCrLf  ' & vbCrLf gives you a carriage return at the end of your code.
No fuss, no muss, no splits necessary because the value of the form input will be the ID and only the ID.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-13-2007, 05:38 PM Re: Splitting a multi-value, multiple select option box into a multidimensional array
Super Talker

Posts: 109
Hey there all...

The reason why I need to list all three is for the users. They won't see the ID. But they do need to see the company and state. I need the IDs because it's easier to pull on the numeric field.

I might try pulling everything after the last comma. That's a great idea.

Thanks everyone,
Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 02-14-2007, 01:46 AM Re: Splitting a multi-value, multiple select option box into a multidimensional array
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
So then do something like this:
Code:
Response.Write "<option value=""" & Trim (rsAtlasTable("ID")) & """>" & trim (rsAtlasTable ("Company")) & ", " & trim (rsAtlasTable ("State")) & "</option>" & vbCrLf
Your users will still see Company, State ... but the value passed will be the ID value (which is the one you want.)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-14-2007, 11:53 PM Re: Splitting a multi-value, multiple select option box into a multidimensional array
Super Talker

Posts: 109
Adam,

Thanks. I took your suggestion and it worked.
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 01:14 AM Re: Splitting a multi-value, multiple select option box into a multidimensional array
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
No prob, Bob.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Splitting a multi-value, multiple select option box into a multidimensional array
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15159 seconds with 12 queries