[Zope] Setting SELECTED in select box

Casey Duncan cduncan@kaivo.com
Tue, 08 May 2001 08:22:01 -0600


Gitte Wange wrote:
> 
> Well I think you are right - this could be the problem.
> 
> But then  - how do I make the test to see if they are identical ?
> fileid proparly is a string and id is an int ... can I convert one of them -
> if so, how?
> 
> Gitte
> 
> On Tuesday 08 May 2001 15:59, Laurie Nason wrote:
> > Have you tried checking to see if one of your 27's is a string and one is a
> > number? I seem to remember that I had this problem before, if I find it I
> > will let you know
> >
> > BTW - you could make the Selected a little snazzier by doing the
> > following.... saves on a few if statements
> >
> > SELECT NAME="fileid" SIZE="1">
> >       <OPTION VALUE="0">-- Select mediafile --</OPTION>
> >       <dtml-in sqlGetMediafiles>
> >           <dtml-if fileid>
> >               <OPTION VALUE="<dtml-var id>"
> >                       <dtml-if expr="fileid == id">SELECTED></dtml-if>>
> >                               <dtml-var filename></OPTION>
> >           </dtml-if>
> >       </dtml-in>
> > </SELECT>
> >

You can convert either automatically using marshalling or using _.int():

<select name="fieldid:int" size="1">
...

The above is converted to an int automatically by Zope and appears as an
int to your DTML.

or

<dtml-if expr="id == _.int(REQUEST.fileid)">

Which does the conversion at the time of the comparison.

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>