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

CFSELECT - Yes/No display values showing as true/false

Guest
Oct 27, 2010 Oct 27, 2010

Copy link to clipboard

Copied

I am having an issue with the code below. All three of the checkboxes work great together. But I am having an issue with some of the data that is being returned by the getResponses method in the third cfselect below. All of the display values being returned are showing correctly (ex. A,B,C,Good,Bad,Approved,Not Approved) in the drop down EXCEPT when the values are "Yes" and "No". For some reason "Yes" and "No" are being returned as "true" and "false" instead.

I have executed the getResponse method outside of the cfselect dumping the returned array and the values are displaying correctly as "Yes" and "No".


<cfselect name="category_cd"
bind="cfc:getCategories(category_cd='#form.category_cd#')"
style="width:300px;"
bindonload="true" /><br>


<cfselect name="question_cd"
bind="cfc:getQuestions(category_cd={category_cd},question_cd='#form.question_cd#')"
style="width:300px;"
bindonload="true" /><br>


<cfselect name="response_id"
bind="cfc:getResponses(question_cd={question_cd},response_id='#form.response_id#')"
style="width:300px;"
bindonload="true" /><br>


In the method I created, I have cast the value from the query, but it still returns as "true" and "false".


<cffunction...>
...
   <cfquery name="qryResponses"...>
        select response_id, CAST(response_txt as char(30)) as response_txt,response_sort_order_nbr,
            CASE WHEN response_id = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.response_id#">               

               THEN 0
               ELSE 2
            END as Sort
        from responses
        where question_nm_cd = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.question_cd#">
   </cfquery>

<cfloop query="qryResponses">
         <cfset responseArray[qryResponses.currentrow][1]=qryResponses.response_id>
            <cfset responseArray[qryResponses.currentrow][2]=qryResponses.response_txt>
        </cfloop>
<cfreturn responseArray>

</cffunction>

Has anyone else experienced this issue with Yes/No values being converted to True/False?

TOPICS
Advanced techniques

Views

1.1K

Translate

Translate

Report

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

correct answers 1 Correct answer

Valorous Hero , Oct 28, 2010 Oct 28, 2010

Seems like the ajax is rendering it as boolean.

Quite possibly. You could try the space hack. Sometimes adding a space to the values is enough to prevent them from being treated as boolean. But check stackoverflow.com too. I know I have seen this question before, but cannot recall if there were more elegant solutions than the space hack ...

Votes

Translate

Translate
LEGEND ,
Oct 28, 2010 Oct 28, 2010

Copy link to clipboard

Copied

I've not experienced the problem, but if I was troubleshooting it, I'd start by dumping the query and the array in that cfc to see at what point the data started to differ from my expectations.

Votes

Translate

Translate

Report

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
Guest
Oct 28, 2010 Oct 28, 2010

Copy link to clipboard

Copied

Dan,

Thank you for responding.  The dump of the array show the correct values in Yes/No format. I believe something is happening to the data when it's bound to the cfselect. Seems like the ajax is rendering it as boolean. Is there a way I can force the type as a string?  Ive tried toString and JavaCast on my array and nothing seems to work. Let me know if you know of something else to try. I'll post back if I figure it out.

Votes

Translate

Translate

Report

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
Valorous Hero ,
Oct 28, 2010 Oct 28, 2010

Copy link to clipboard

Copied

Seems like the ajax is rendering it as boolean.

Quite possibly. You could try the space hack. Sometimes adding a space to the values is enough to prevent them from being treated as boolean. But check stackoverflow.com too. I know I have seen this question before, but cannot recall if there were more elegant solutions than the space hack ...

Votes

Translate

Translate

Report

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
Guest
Oct 29, 2010 Oct 29, 2010

Copy link to clipboard

Copied

LATEST

-==cfSearching==- wrote:

Seems like the ajax is rendering it as boolean.

Quite possibly. You could try the space hack. Sometimes adding a space to the values is enough to prevent them from being treated as boolean.  But check stackoverflow.com too. I know I have seen this question before, but cannot recall if there were more elegant solutions than the space hack ...


Thank you, that did it.  I will keep looking for a sexier fix, but for now this will do the trick.  Much appreciated!

Votes

Translate

Translate

Report

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
Documentation