[Zope] dtml-in question

Randall F. Kern randy@spoke.net
Tue, 3 Apr 2001 10:25:08 -0700


I would suggest flattening your loop, like this:

<form action=3D"myaction">
<table>
<dtml-in expr=3D"_.range(100)">
  <dtml-if expr=3D"_['sequence-index'] % 10 =3D=3D 0">
    <dtml-unless sequence-start>
      </tr>
    </dtml-unless>
    <tr>
  </dtml-if>
    <td><input type=3D"text" name=3D"box:list" size=3D"3"></td>
</dtml-in>
</tr>
</table>
</form>

This will create 100 (or any number) of input boxes.  It's also easier
to change how many boxes you want per line, just change the 10 in the if
statement.  You can also more easily support a total number of boxes
that isn't a multiple of your row length.

By naming the input boxes "box:list", a single sequence named box will
be passed to your method "myaction".  This will probably be easier than
100 different names.

-Randy
> -----Original Message-----
> From: Russell Hires [mailto:rhires@earthlink.net]
> Sent: Tuesday, April 03, 2001 10:14 AM
> To: Phil Harris
> Cc: zope@zope.org
> Subject: Re: [Zope] dtml-in question
>=20
>=20
> Why of course!
>=20
> I want to create a table of input boxes. The way I wanted to=20
> do this was by
> creating a row of boxes, then going to the next row and=20
> creating ten more
> boxes.
>=20
> In the course of writing this, I couldn't remember what I had=20
> originally
> done that didn't work. But in trying to duplicate it, it does=20
> work now:
>=20
> <table>
> <dtml-in "_.range(10)">=20
>   <tr>=20
>   <dtml-in "_.range(10)">
>    <td><form>
>    <input type=3Dtext name=3D"foo" size=3D3>
>   </dtml-in>
>  </dtml-in>
>  </table>
>=20
> Of course, at this point, using this code, I have 100 input=20
> boxes with the
> same name. How do I introduce a counter that will give me 100=20
> different
> names for the boxes (or whatever number of boxes the user=20
> wants to create)?
>=20
> Thanks for your help.
>=20
> Russell
> ____________________________________________________
>   _its_ (no apostrophe) means "the thing that it owns"
>   _it's_ (with apostrophe) means "it is"
>=20
>=20
> ----------
> >From: "Phil Harris" <phil.harris@zope.co.uk>
> >To: "Russell Hires" <rhires@earthlink.net>, <zope@zope.org>
> >Subject: Re: [Zope] dtml-in question
> >Date: Tue, Apr 3, 2001, 10:17 AM
> >
>=20
> > Nesting dtml-in is very possible.
> >
> > I don't quite get from your explanation what your trying to=20
> do though.
> >
> > Could you elucidate slightly.
> >
> > Phil
> >
> > ----- Original Message -----
> > From: "Russell Hires" <rhires@earthlink.net>
> > To: <zope@zope.org>
> > Sent: Tuesday, April 03, 2001 3:08 PM
> > Subject: [Zope] dtml-in question
> >
> >
> >> Is it possible to nest <dtml-in> tags?
> >> Actually, I know it isn't because that's something I've=20
> tried already and
> > it
> >> didn't work. At least, it didn't work the way I tried it.
> >>
> >> I'm just getting my feet wet with dtml, and I created a=20
> table using one
> > dtml
> >> method to create one row of the table using the <dtml-in>=20
> tag, but it
> > seems
> >> silly to have to have a completely separate method for one=20
> <tr> tag in a
> >> method all by itself.
> >>
> >> I did solve the problem this way: I created one method=20
> with the definition
> >> of one row of a table, then created another method with=20
> one <tr> tag to
> >> create the next row of the table, then looped using=20
> <dtml-in> first-method
> >> second-method</dtml-in>. It just seems kinda klunky...
> >>
> >> Thanks for any help!
> >>
> >> Russell
> >
>=20
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>=20