Dieter:
Could you explain a little more I still seem to be trying to input
everything all on one record. I need to break out in an array then each
needs to be added to the database as a separate record. Maybe I missed
something.
Thanks,
Todd
Todd Loomis writes:
> I want to insert to a database a id and a option, however each id
can have
> more than one option. And I want them inserted separately to make
2
records.
>
> The form will be checkboxes they check all the options they want and
they
> all get save in the database seperately but with the same id. I've
tried to
> no luck. Can anybody help?
Some basic observations:
ZSQL Method bodies are DTML objects. You use DTML there to generate
SQL in the same way you use DTML usually to generate HTML.
Especially, you have the "dtml-in" in order to iterate
over
sequences.
A ZSQL Method can generate and execute several SQL commands.
These commands need to be separated by "<dtml-var
sql_delimiter>".
Thus, you use something like:
<dtml-in options>
insert into ...
<dtml-unless sequence-end><dtml-var
sql_delimiter></dtml-unless>
</dtml-in>
You need to be a bit careful with your options in the form.
It should probably contain something like:
<input type="hidden" name="options:list"
value="dummy">
...
<input type="checkbox" name="options:list"
value="...">
...
The hidden variable ensures that you always get something for
options.
The ":list" ensures that the case of a single option leads to a
list
as well as multiple options.
When you use the hidden variable approach as shown above, then
your options list contains a bogus first element. You need to drop
it again. The "dtml-in options" above becomes 'dtml-in
expr="options[1:]"'.
Dieter
_______________________________________________
Zope maillist - Zope@z...
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
)