[Zope] Returning and showing value of a checkbox

Don Brooksby DonB@clh.com
Wed, 22 Jan 2003 09:55:34 -0700


I've got progress! I have been doing major head-banging testing based on =
the info received with this problem.  I may be doing this the long way, =
or maybe I am just understanding what was told to me.  However, Here is =
what I am doing to resolve this issue.

Process that happens before this form pops up:
1) Admin user wants to edit an article, they are viewing a snipet of the =
article info, they click on the Edit button.

2) The request to the db is placed and the data is brought in to the =
editing form...where the problem rests.

Now what I have had success with...
The info populates the form based on dtml requests to grab the data from =
the variables in the request to the database.

a) Where the checkboxes are, I test the value of "main" (the variable =
holding either a 1 or 0) by doing the following:
     <td><b>Main:</b></td>
     <td><input type=3D"text" name=3D"main" value=3D"<dtml-var main>">
         <dtml-if "main=3D=3D'1'">
            <input type=3D"checkbox" name=3D"newmain" checked>
         <dtml-else>
            <input type=3D"checkbox" name=3D"newmain" value=3D"1">
         </dtml-if></td>
b) where the value of "main" =3D=3D 1, the box is checked, if 0 the box =
is unchecked and if it gets checked during the Editing of the article, =
the value of 1 will then be written back to the proper field in the =
table of my db.

This seems to be working and my sincere thanks to all who have helped. =
This is a normal programming way of testing the value of a variable, =
however, I think I got a bit lazy with some features and functions of =
Zope.  Much thanks to all! BTW, for some reason, my headache is gone. :)

Don


On Wednesday, January 22, 2003 9:37 AM, Dylan Reinhardt wrote:

At 04:07 AM 1/22/2003, Schmidt, Allen J. wrote:
>"Checkboxes don't have a value attribute." ???
>
>Since when?
>I've been using values on checkboxes since I have been building web
>forms....going on 10 years now... adding checked only determines =
whether it
>is checked or not be default when the form loads.

Ah, true enough.  I had to go look it up, but you're right. Thanks for=20
pointing out my goof.

You can assign a value attribute that determines what the *inbound* =
value=20
of a checked box will (should) be.  A useless feature, perhaps, but one=20
that is most surely there.

The value attribute still has nothing to do with whether the box is=20
displayed as checked or how you catch the data and stuff it in your =
db...=20
which still seems to be the problem faced by the original poster.  The =
OP=20
was trying to figure out why his forms weren't displaying the correct=20
"values" for the checkboxes.  Either he needed to know how to check for=20
their state coming in or how to set it going out.  Ultimately, the value =

attribute is germane to neither question and he seemed to expect it to =
do=20
stuff it simply doesn't do.

My apologies for any confusion.  I should keep my Pocket Reference out =
when=20
I post on HTML.  :-)

Dylan


_______________________________________________
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 )