Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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

 
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.
======================================




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





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