[Templates] Foreach Question
Dennis Daupert
ddaupert@csc.com
Mon, 16 Sep 2002 09:45:22 -0500
Hi folks,
Has anyone dealt with this kind of situation?
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. The page displays rows out of my database, and
allow the user to enter info/update info by clicking the button
associated with the selected row. There are a few odd problems
associated with this arrangement. Does someone have a
good approach to handling this kind of situation?
Here is a code example of a page that displays a couple of dropdown
menus, as well as a clickable link to a popup date-picker calendar:
[% 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">
<br><TEXTAREA NAME="doos" ROWS="5" COLS="50">[% agendaitems.agendaitem
%]</TEXTAREA>
<br><b>Assign To:</b> [% CGI.popup_menu("assignee", users) %]
<br><b>Importance:</b> [% CGI.popup_menu("importance", [ 'low' 'medium'
'high']) %]
<br><b>Target Date:</b> <input type=text name="target_date" value=""
size=15><a href="javascript:show_calendar('assignform.target_date');"
onmouseover="window.status='Date Picker';return true;" onmouseout
="window.status='';return true;"><img src="/show-calendar.gif" width=24
height=22 border=0></a>
<br><INPUT TYPE="hidden" NAME="itemid" VALUE="[% agendaitems.itemid %]">
<br><INPUT TYPE="hidden" NAME="status" VALUE="assigned">
<br><INPUT TYPE="submit" VALUE="Assign">
</FORM>
<br>
[% END %]
The biggest problem on this one is that if I only have one row in the db,
the popup date picker works just fine;
but if there are more items, the multiple forms with same textbox names
confuse javascript, and the
popup itself then displays the updated page, but without the selected date.
Also after updating, the refreshed
page shows the same assignee and importance for all displayed forms.
Any suggestions?
/dennis
---------------------------------------------------------------------------
Office phone: 817-762-8304
---------------------------------------------------------------------------
Seen on a Texas bumper sticker:
Fail until you succeed.