[Zope] Returning and showing value of a checkbox
Don Brooksby
DonB@clh.com
Tue, 21 Jan 2003 18:02:45 -0700
On: Tuesday, January 21, 2003 5:38 PM, Jim Penny wrote:
> DTML:
> <td><input type=3D"checkbox" name=3D"newmain" <dtml-if =
main>"checked"</dtml-if >
> ZPT:
> <td><input type=3D"checkbox" name=3D"newmain" =
tal:condition=3D"checked repeat_var/main">
> OK?
>Jim
*Sigh* I may have messed this and you up. I am regrouping and looking =
at what I am trying to do. Jim, that was a very good idea and what it =
looks like, maybe I should be using Python to grab the data from my db?
Neither the DTML or the ZPT worked in this instance. The form I am =
bringing in the data that has already been saved, it still does not =
bring in the check...WAIT! should I be saving the value of the checked =
box, into my table, as "checked" rather than "1"??? or does it even =
matter.
By further explanation: in the Method before this form, where I issue =
the call to the dbtable to extract an exact article, I save the value of =
the checkbox (main) to a variable called Main. I then Set the value to =
Main in the updateArticle_html (my form to view the data). This is the =
form that I am having the problem with.
It seems that where you issue the <input type=3D"checkbox"...> any value =
stated is what the value of the checkbox is when you write the value =
out. But when you want to read the value and the checkbox showing as =
checked is seems that the form needs to be referencing some other =
function rather then the <input type=3D"checkbox"...> Am I off?
Don
On Tue, Jan 21, 2003 at 05:12:05PM -0700, Don Brooksby wrote:
> I know how to process a form with checkboxes, but when I have stored a =
value of the checkbox and want to edit it, I can't seem to get it to =
populate the checkbox in my form.
>=20
> I have tried to bring in the value of the checkbox, in this case 1 =3D =
checked and 0 =3D not checked. This data was processed in the original =
form and I saved it to a table in PostgreSQL. I query the table and =
retrieve the value of the check box. This is where I am hitting my head =
on that brick wall (about 6' up, dead center).
>=20
> I can populate the form for editing with everything except the =
checkboxes; i.e. unique id#, title, written by, article body, etc...
>=20
> I have even tried to do:
> <td><input type=3D"checkbox" name=3D"newmain" value=3D"<dtml-var =
main>"></td>
>=20
> ...so that box will show it checked...I error out.
>=20
> Have I cleared it up?
> Don
On Tuesday, January 21, 2003 5:04 PM, Jim Penny Wrote:
On Tue, Jan 21, 2003 at 04:42:58PM -0700, Don Brooksby wrote:
> I am a 1 year old newbie and 1st time participant to the email =
group...working on a total website using PostgreSQL in the background. =
I have hit a wall where help would be appreciated.
>=20
> In a nut-shell, I have an area where employees can submit articles of =
industry info for our customers. In that article submission they check =
off a checkbox denoting what specific customer sub-web they want it =
published. I then have an area where they can go back in and edit the =
article or delete totally.
>=20
> The only problem I have is showing in the checkboxs what was selected =
when they first submitted the article. Of course when I have the =
following:
>=20
> I bring in the value from another DTML Method reading the request from =
PostgreSQL:
> <input type=3Dhidden name=3D"main" value=3D"<dtml-var main>">
>=20
> In the form I have the checkbox show up in the form, but it is not =
checked if the value
> pulled from the db is appropriate:
>=20
> <td><b>Main:</b></td>
> <td><input type=3D"checkbox" name=3D"newmain" value=3D"1"></td>
>=20
> I have tested that the value is appropriate, but cannot figure how to =
show that checkbox as filled if it is supposed to be (1 as checked and 0 =
as not checked).
>=20
> I am figuring that Python will be the solution, but if the employee =
wants to uncheck the box, how is that handled with a dtml instance?
Don: this question is a bit confused....
1) Do you want to know how to create a form which has a checkbox which
is pre-checked depending on the query?
2) Do you want to know how to process forms with checkboxes in them?
or=20
3) both?
Jim
>=20
> Thank you
> Don Brooksby
>=20
> _______________________________________________
> Zope maillist - Zope@zope.org
> 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 )