[Zope] Incrementing a form field

administrator@consotec.de administrator@consotec.de
12 Dec 00 15:46:14 UT


--------------1DD2510B41FE
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

If you are working with MySQL or some other database system,
then your database should deliver a valid id.
For a description have a look in the HowToDos and search for:
Creating a new record with subrecords in MySQL

Best regards
  Arno
> Hi!
> 
> I have a form that is used to insert some records to a database, and one
> of the fields is a sequence number. I want to increment this number when
> the form is used, unless is the first time it is loaded.
> 
> The form (idea copied from the SmartForms HOWTO) have the name
> "Register", and is something like this:
> 
> <dtml-var standard_html_header>
> 
> <dtml-if "REQUEST.REQUEST_METHOD=3D=3D'POST'">
>   Record inserted.
> </dtml-if>
> 
> <dtml-if my_number>
>   <dtml-call "REQUEST.set('my_number', my_number + 1)">
> <dtml-else>
>   <dtml-call "REQUEST.set('my_number', 1)">
> </dtml-if>
> 
> <form action=3D"Register" method=3D"POST">
> A Field <input name=3D"my_field" value=3D"some value"><br>
> A Number <input name=3D"my_number" value=3D"<dtml-var my_number>"><br>
> <input type=3D"submit" value=3D"OK">
> </form>
> 
> <dtml-var standard_html_footer>
> 
> It work for the first load, but when I press the OK button, I get an
> error message:

--------------1DD2510B41FE--