On Thu, Apr 27, 2006 at 09:18:30AM +1000, Seona Bellamy wrote:
> Hi guys,
>
> Can someone please look at this and tell me what's wrong with it? I'm sure
> it's something really simple, but I just can't see it.
>
> I have the following piece of code:
> <cfinput class="chkb" name="advertising" id="advertising" type="checkbox"
> value="1"<cfif form.advertising> checked="checked"</cfif>>
>
> It gives me the following error:
> -----------------
> Invalid token 'c' found on line 194 at column 121.
> The CFML compiler was processing:
> * a cfinput tag beginning on line 194, column 38.
> * a cfinput tag beginning on line 194, column 38.
> * a cfinput tag beginning on line 194, column 38.
> * a cfinput tag beginning on line 194, column 38.
> The error occurred on line 18.
> ----------------
>
> If I remove the <cfif> bit, the error goes away. Can I not have a <cfif> in
> a <cfinput>? I'm sure I've done it before.
Correct, this is something you can't do. I suspect that at some point
you've had a <cfif> inside a plain HTML <input> tag, which is perfectly
fine. In this case the <input> tag is nothing but text to be spat out,
as far as CFML is concerned. On the other hand, <cfinput> is more akin
to a function call to be processed.
A direct analogue to what you'd like to do would be:
<cfif form.advertising>
<cfinput class="chkb" name="advertising" id="advertising"
type="checkbox" value="1" checked="checked">
<cfelse>
<cfinput class="chkb" name="advertising" id="advertising"
type="checkbox" value="1">
</cfif>
Luckily, according to the 6.1 docs that I just had a glance at:
CHECKED
Selects a control. No value is required.
Applies if type = "radio" or "checkbox".
Optional: you can enter the following values:
* true (equivalent to checked)
* false (equivalent to omitting the attribute)
In your case, what this means is that "checked" (the value you're giving
the attribute) is being parsed as 'true'. It also means that:
<cfinput class="chkb" name="advertising" id="advertising" type="checkbox"
value="1" checked="#form.advertising#">
is equivalent to the above.
HTH
-T
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---