sorting a text box
3 posts by 3 authors in: Forums > CMS Builder
Last Post: October 18, 2012 (RSS)
By Mel - October 17, 2012
I have a record field called locations which is a text box
In the text box are a variety of location names entered in no particular order and with out any commas separating them
Each record has different location names and a different amount of entries in that field
Is there a way that I can sort these location names into alphabetical order when they are displayed for each record in it's present format?
Or do I need to be entering this data in a different way instead of a text box
Thank you - Mel
In the text box are a variety of location names entered in no particular order and with out any commas separating them
Each record has different location names and a different amount of entries in that field
Is there a way that I can sort these location names into alphabetical order when they are displayed for each record in it's present format?
Or do I need to be entering this data in a different way instead of a text box
Thank you - Mel
Re: [mel] sorting a text box
Hi Mel,
I don't think that you can easily sort the words in a text box directly, but I've been proved wrong by the coding gurus at Interactive Tools before.
Is there a finite list of locations? How do the locations get entered into the text box. Are there any controls as to how that's done?
As far as trying to sort the text in a text box, you may be able to create an array out of the text using the PHP explode function http://php.net/manual/en/function.explode.php
Then you could try sorting the array alphabetically using the PHP sort function http://php.net/manual/en/function.sort.php
I think that you'd have to put together some code to make sure that your location names are in a specific format, and I don't know how you would deal with multi-word location names, but it's an approach you could explore if you think it might work.
If you need more help you could go the consulting route consulting@interactivetools.com. Consulting is usually fast and cost effective.
Best,
Jerry Kornbluth
[email]
I don't think that you can easily sort the words in a text box directly, but I've been proved wrong by the coding gurus at Interactive Tools before.
Is there a finite list of locations? How do the locations get entered into the text box. Are there any controls as to how that's done?
As far as trying to sort the text in a text box, you may be able to create an array out of the text using the PHP explode function http://php.net/manual/en/function.explode.php
Then you could try sorting the array alphabetically using the PHP sort function http://php.net/manual/en/function.sort.php
I think that you'd have to put together some code to make sure that your location names are in a specific format, and I don't know how you would deal with multi-word location names, but it's an approach you could explore if you think it might work.
If you need more help you could go the consulting route consulting@interactivetools.com. Consulting is usually fast and cost effective.
Best,
Jerry Kornbluth
[email]
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [mel] sorting a text box
By rconring - October 18, 2012
If I were setting this up, the locations would be stored in a related records table and I would use a multi-select list to choose as many locations that apply to that record. Then on the display page, sort the related records by name.
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987