Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 8th, 2003, 04:34 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create an Array from a multiple select box

This may sound relatively simple, but there is a twist.

The twist is that I need to take the values selected from a multiple select box, (which normally wouldn't be that bad - just split at the comma), but the data that populates the select box already contains commas.

Ex: last name, first name
    1. Jones, John
    2. Morris, Mike

If you were to split at the commas, you would get an array with data like:

'Jones', 'John', 'Morris', 'Mike'

But what I really need is:

'Jones, John', 'Morris, Mike'

Notice the difference?

I'm sure this is something that is encountered from time to time, but I just can't seem to figure out how do it right now. I would greatly appreciate any assistance you can offer.

Thanks

Reply With Quote
  #2 (permalink)  
Old August 10th, 2003, 08:51 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You could convert the 1st and every second comma then on into another character such as * using the 'mid' function and 'mid' statement.
Then split it.
Then loop through the array and replace the * again.

or...

You could leave the comma out of the value in the first place.
And add a comma to the space with 'replace' later if required
eg.
Code:
<select name="mySelect" multiple etc>
    <option value="Jones John">Jones, John</option>
    <option value="Morris Mike">Morris, Mike</option>
</<select>
But...
If the first and last names have come from a DB I would look into using the index of the record as the select inputs value attribute and working arround it that way.

Depends on what you wish to do with the values next.

Rod

======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple select box question cstooch Classic ASP Professional 5 December 10th, 2007 06:56 PM
Multiple select box vinikz Java Databases 1 September 4th, 2007 07:21 AM
Populating a multiple select box from a database ozzii Classic ASP Databases 0 February 15th, 2007 06:40 AM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM



All times are GMT -4. The time now is 11:19 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.