Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfselect with bind truncates leading zero

New Here ,
Nov 11, 2009 Nov 11, 2009

Banging my head against this one. I have two cfselect menus using bind. The first one populates the second. It's working fine except for this one wrinkle: the second select menu gets populated with zip codes. If they have leading zeroes (e.g. 02842) the zero gets clipped. The datatype in MySQL is char(5).

If I just throw a regular query on the data and dump it it comes back with the zeroes fine.

Bug? Workaround?

CF8 BTW.

Thanks.

TOPICS
Getting started
768
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 11, 2009 Nov 11, 2009

Workaround - instead of binding, invoke the method and use the returned query.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2009 Nov 12, 2009

But if I just invoke the method (which I know returns results with the zero respecting the char datatype) doesn't that kill the interactivity between the bound menus? Right now when you select a state from the first menu a list of available delivery areas determined by zip code is returned. So I want to preserve that ability. I don't want to just list every zip in the database. So am I missing some trick with invoke vs bind?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 12, 2009 Nov 12, 2009

Here is an example of related selects without using binds.  http://www.pathcom.com/~bracuk/code/RelatedSelects.htm

It may or may not be appropriate for your situation.  I remember something on these forums a few years back about performance problems if you used this approach with too much data.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2009 Nov 12, 2009

Thanks. I'll give them both a try.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 12, 2009 Nov 12, 2009

And then there's the simple workaround.  Use NumberFormat to force your zip codes to have 5 characters.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 11, 2009 Nov 11, 2009
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2009 Nov 12, 2009

Thanks for the link. What a clunker but if it works it works. I'll post either way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2009 Nov 12, 2009
LATEST

The "stupid hack" did it.

Thanks for your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources