Barry,
Try it the way Adrian suggested - much cleaner - and only one line of code:
<cfinput type="checkbox" name="all" checked="#isDefined('form.all')#">
Also, check this - do you have a <cfparam name="form.all" default=""> line
at the top of your code? If so, that changes how you need to code the
cfinput line.
Dave
-----Original Message-----
From: Barry Mcconaghey [mailto:[email protected]]
Sent: Wednesday, July 15, 2009 9:12 AM
To: cf-newbie
Subject: Re: Session Variables
Hi Dave.
I added your code but it still does not save the visitors checkbox (All 50
States)
<cfif isDefined("form.all")>
<cfinput type="checkbox" name="all" checked="yes">All 50 States
<cfelse>
<cfinput type="checkbox" name="all">All 50 States
</cfif>
Here is the link. Try typing the wrong captcha text and uncheck "All 50
States".
http://www.firefightingnews.com/contact_us_directory.cfm
Thanks,
Barry
>You don't really need the session variables since you are posting the form
>to itself. You can just reference the variables with the form scope.
>Session variables are if you need to persist values from one page to
>another. In any case, you can do this to get your checkboxes:
>
><cfif isDefined("form.checkall")>
> <cfinput type="checkbox" name="checkall" checked="yes">
><cfelse>
> <cfinput type="checkbox" name="checkall">
></cfif>
>
>A checkbox exists in the form scope upon a submission ONLY if it is
checked.
>So, we check to see if it is defined and if it is, then we know the box was
>previously checked, and so we execute the cod that will display it as
>checked. If the form.checkall variable is NOT defined, then the checkbox
>wasn't checked (or the form scope doesn't even exist, like on the first
time
>load of the page) and so we don't display it checked.
>
>Hope this helps.
>
>Dave Phillips
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4628
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15