[Templates] Foreach Question

Chris Winters chris@cwinters.com
Mon, 16 Sep 2002 11:21:07 -0400


* Dennis Daupert (ddaupert@csc.com) [020916 10:59]:
> I have several pages in which I have embedded forms
> inside a foreach. Because the same form repeats on the page,
> the textbox names, textarea names, etc all repeat as well, of
> course.
> ..
> [% FOREACH agendaitems = DBI.query('SELECT * FROM agendaitems ORDER BY
> mtg_date') %]
>    <hr>
>    <b>Author: [% agendaitems.author %] - Status: [% agendaitems.status %] -
> Assignee: [% agendaitems.assignee %] </b>
>    <FORM METHOD="GET" name=assignform  ACTION
> ="/tt2/agendoo/adm_assign_items">

Try naming the form differently for each row. For instance:

    <FORM METHOD="GET" name="assignform[% loop.count %]"
          ACTION="/tt2/agendoo/adm_assign_items">

and then change your javascript:

 ...
 <a href="javascript:show_calendar('assignform[% loop.count %].target_date');"
 ...

I've done something like this before and haven't had any problems with
it as long as the forms are named something different.

Chris

-- 
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988