Skip to main content
Inspiring
November 19, 2008
Question

CF form field question

  • November 19, 2008
  • 3 replies
  • 508 views
I have:

<cfinput name="OpenFoil" readonly="#iif(url.e eq 0,de('yes'),de('no'))#"
type="checkbox" value="1" checked="yes" onClick="optionFoil(this.form)">

I would like to check the box if url.e is 0. When I try the above code,
I can still check the box, and uncheck it, its not read only...... Will
this not work the way I want?


    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    November 20, 2008
    So, where have I gone wrong????
    You may not nest CFML statements or tags within cfinput's attribute space.
    This is no good: <cfinput <cfoutput>#aVar#</cfoutput>>.
    Neither is this: <cfinput #someEvaluation#>.




    Inspiring
    November 20, 2008
    Hello BKBK,

    So I'm confused, that was your code:

    The correct attribute is disabled attribute], not readonly. Its function
    in for HTML forms is slightly different from that in Flash forms. The code
    follows.

    <cfform format="HTML">
    <input name="OpenFoil" <cfoutput>#iif(url.e eq
    0,de('disabled="disabled"'),de(''))#</cfoutput>
    type="checkbox" value="1" checked="yes" onClick="optionFoil(this.form)">
    </cfform>

    <cfform format="Flash">
    <cfinput name="OpenFoil" disabled="#iif(url.e eq 0,de('yes'),de('no'))#"
    type="checkbox" value="1" checked="yes" onClick="optionFoil(this.form)">
    </cfform>

    And now you're saying that you can't do that?????



    > So, where have I gone wrong????
    > You may not nest CFML statements or tags within the cfinput's
    > attribute space.
    > This is no good: <cfinput <cfoutput>#aVar#</cfoutput>>.
    > Neither is this: <cfinput #someEvaluation#>.


    BKBK
    Community Expert
    Community Expert
    November 20, 2008
    The correct attribute is cfinput's disabled, not readonly. Its function in for HTML forms is slightly different from that in Flash forms. The code follows.


    added edit: The repetition isn't intended. I wasn't aware of Azadi's post when I submitted.


    Inspiring
    November 20, 2008
    Hello BKBK,

    Ok, its odd, if I have:

    <cfinput name="OpenFoil" #iif(url.e eq 0,de('disabled'),de(''))# type="checkbox"
    value="1" checked="yes" onClick="optionFoil(this.form)">

    I get:
    Invalid CFML construct found on line 280 at column 61.
    ColdFusion was looking at the following text:
    #

    If I have:
    <cfinput name="OpenFoil" <cfoutput>#iif(url.e eq 0,de('disabled'),de(''))#</cfoutput>
    type="checkbox" value="1" checked="yes" onClick="optionFoil(this.form)">

    I get:
    Invalid token c found on line 280 at column 62.

    So, where have I gone wrong????




    > The correct attribute is disabled attribute], not readonly. Its
    > function in for HTML forms is slightly different from that in Flash
    > forms. The code follows.
    >
    > <cfform format="HTML">
    > <input name="OpenFoil" <cfoutput>#iif(url.e eq
    > 0,de('disabled="disabled"'),de(''))#</cfoutput>
    > type="checkbox" value="1" checked="yes"
    > onClick="optionFoil(this.form)">
    > </cfform>
    > <cfform format="Flash">
    > <cfinput name="OpenFoil" disabled="#iif(url.e eq
    > 0,de('yes'),de('no'))#"
    > type="checkbox" value="1" checked="yes"
    > onClick="optionFoil(this.form)">
    > </cfform>


    Inspiring
    November 20, 2008
    try the DISABLED attribute instead...
    READONLY attribute applies to TEXT input fields only.

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/