Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



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

Posts: 116
Trades: 0
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
 
 
Register now for full access!
Old 02-07-2007, 07:33 PM Re: Splitting a multi-value, multiple select option box into a multidimensional array
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
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, 04:01 AM Re: Splitting a multi-value, multiple select option box into a multidimensional array
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
yep you can use InstrRev or Right to locate it
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-08-2007, 02:40 PM Re: Splitting a multi-value, multiple select option box into a multidimensional array
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-13-2007, 06:38 PM Re: Splitting a multi-value, multiple select option box into a multidimensional array
Super Talker

Posts: 116
Trades: 0
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, 02:46 AM Re: Splitting a multi-value, multiple select option box into a multidimensional array
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
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.)
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-15-2007, 12:53 AM Re: Splitting a multi-value, multiple select option box into a multidimensional array
Super Talker

Posts: 116
Trades: 0
Adam,

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

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
No prob, Bob.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.54286 seconds with 12 queries