Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing out substrings from a form field

Status
Not open for further replies.

rockyroad

Programmer
Feb 22, 2003
191
US
Hello,

I have one form field - basically "Find Location by City, State or Zip". There needs to be just one form field.
I will have a DB backend that will do the "lookup"... What I'd like to do is have ColdFusion do a preliminary parsing of the value of the string submitted in the field... Basically to look at a delimited list of parts of the string where the delimiter is a "space"... I'd need to then look for things like - "if the first 5 characters are numeric, then I know it's a zip, so run the query by zip against a zip table (or column)... if not, then take the string and parse out possible City / State combinations and send those values against a query... Any thoughts on how I should approach this? I am thinking I may need to use string functions, and a loop list and maybe a temp query, but I am a little stuck on where to begin. Any thoughts?

Thanks!
 
I do this with a user-defined function in the database. Wherever you accomplish this, though, you're going to have a lot of fun interpreting user input!

Good luck!

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Pity the insomniac dyslexic agnostic. He stays up all night, wondering if there really is a dog.
 
My first thought is:

On the action page do a

<cfset newStr=replace(form.str,' ',",",'ALL')>

then do a query

Where zip IN ("#newStr#")
OR City IN ("#newStr#")
OR State IN ("#newStr#")

and see what kind of performance you get.

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top