[ZPT] Another attribute state trick

Scott Burton mrzope@hotmail.com
Sat, 01 Dec 2001 02:10:39 +0000


Here's another good one. If you have two checkboxes and you wanted one or 
the other checked based on a condition. You can do this:
<tal:block define="global return_visit python:request.has_key('SiteCookie')" 
/>
<tal:block define="global first_visit python:not 
request.has_key('SiteCookie')" />

Then for the checkboxes:

<input tal:attributes="checked first_visit"
                       type="radio" name="customer_type"
                       value="new_cust">

and

<input tal:attributes="checked return_visit"
                       type="radio" name="customer_type"
                       value="return_cust">

So if they have been there before the appropriate radio button will be 
checked. I can imaging many more uses of this.



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp