[Zope] problem with dtml-if

Thomas Weiner weiner@tu-harburg.de
Thu, 30 Mar 2000 12:54:49 +0200


Anders Holmbech Nielsen schrieb:
> 
> hi,
> 
> I have this code in a dtml method called "test":
> 
> <HTML><body bgcolor=#ffffff>
> 
> <form action="test" method="get">
> 
> <SELECT NAME="day">
>         <dtml-in
> "(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
> ,27,28,29,30,31)">
>                 <OPTION VALUE="<dtml-var sequence-item>"<dtml-if
> "_['sequence-item'] == day"> SELECTED</dtml-if>>
>                         <dtml-var sequence-item>
>                 </OPTION>
>         </dtml-in>
> </SELECT>
> 
> <input type="SUBMIT" name="SUBMIT" value="go">
> </FORM>
> </BODY></HTML>
> 
> It should "remember" the day selected and choose that as the default
> when making the select box. But for some reason the sentence:
> <dtml-if "_['sequence-item'] == day"> SELECTED</dtml-if>
> 
> Doesn't work. I have also tried ... == _[day] ... == 'day'
> ...and a lot of other stuff but with no positive result.

That's because 'day' in the request is a string which you compare to an
integer.
Try:

<dtml-if "_['sequence-item'] == _.int(day)"> and your code should work
fine.

BTW you can shorten you <dtml-in> statement with the range tag:

<dtml-in "_.range(31)"> will give you the same output.

Hth,
Thomas


> I start the page with zope:8080/test?day=1
> 
> Regards
> 
> -------------------------------------------------
> Anders Holmbech Nielsen | Tlf:  (+45) 70 22 56 00
> Software Engineer       | Fax:  (+45) 70 22 57 00
> Integrator Uniware A/S  | http:/www.integrator.dk
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )

-- 
fon: ++49 (0)40 42878 3781
fax: ++49 (0)40 42878 2728