J.J.Baxter - My place on the web - interests, hobbies, thoughts & ruminations
Home / Blog
Books
Links
Images
Aug Sep-2010 Oct
SMTWTFS
2930311234
567891011
12131415161718
19202122232425
262728293012
3 4 5 6 7 8 9
Reset Calendar
Snorg Girls
Programming Tips
Sherlock Holmes
Mythbusters
Gallipoli
Nova Science Now
Ajax Loading Images
The Girls of Dr. Who
Keratosis Pilaris (KP)
Amazing Water
Buy me a drink? I'll have a Cappuccino, thanks.
Random Images
Random Link
Tahlei's PhotoBlog
Random Book
The Moor
by Laurie R King






All Rights Reserved 2008
JJBaxter.com

J.J.Baxters Development Tips & Snippets
backBack
 Beware the Splitting of multivalue select options (ASP : 06-Nov-2008)
This just kept me tied up for 3 hours. I was allowing a customer to select multiple values from a html select box then processing the values after splitting them into an array, like this:

sCompetencies = Request.Form("competencies")
aCompetencies = split(sCompetencies & ",",",")
'aCompetencies is now an array that holds all the clients selections

Now this worked just fine for many months until the client noticed that previously selected values were not being found. After scanning the SQL table I found the missing competencies, but they all had leading spaces?

After much head scratching and lots of debugging I found that HTML feeds multi-select option values delimited with a comma and a space! My code split the values just fine but the second and subsequent values all had the space at the beginning, which I was writing to my SQL Table.

I repaired the table values and everywhere I use the above code I added the following after the split line:

for i= 0 to ubound(aCompetencies) - 1 ' for each competency that the course awards
   aCompetencies(i) = trim(aCompetencies(i)) ' remove spaces !!!!!!!!!!!!!!!!!!!!!!!!!!
next

Problem solved