You can often shorten this code block from...

> <cfif isDefined("form.checkall")>
>       <cfinput type="checkbox" name="checkall" checked="yes">
> <cfelse>
>       <cfinput type="checkbox" name="checkall">
> </cfif>

to...

<cfinput type="checkbox" name="checkall"
checked="#IsDefined('FORM.checkall')#">

Adrian

> -----Original Message-----
> From: Dave Phillips [mailto:[email protected]]
> Sent: 15 July 2009 05:39
> To: cf-newbie
> Subject: RE: Session Variables
> 
> 
> 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:4626
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to