Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Checkbox Question

Quote Reply
Checkbox Question

I have added a new field to the Post table using admin.cgi. I have also added this field to the include_post_html_common_write.html template as a check box.

In testing, when I check the check box, the value associated with this field is stored correctly after the make changes button is pressed. When editing the post, I check to determine if the field in the database is filled. If the field is filled I set the check box to checked.

However, I have noticed that if I uncheck the check box that fact is not stored in the database. In short, I can't uncheck the check box and have that fact stored in the database. What I would like to do is to mimic the behavior exhibited by the check boxes at the bottom of this form. In short, my implementation of this forum permits the client to edit their posts and they can uncheck or check the check boxes. If the client unchecks a check box or boxes they remain unchecked when the client returns to this form.

Can anyone provide some insight as to what I need to do to accomplish what is stated above. Any assistance will be appreciated.

Thank you,

Quote Reply
Re: [jbzipperian] Checkbox Question In reply to
The easiest way to do it might be with a little bit of Javascript and a hidden field. So, you'll end up with something like this:


<input type=hidden name=post_mycheckbox value=<%if post_mycheckbox%>1<%else%>0<%endif%>>
<input type=checkbox onclick="var c; if (this.checked) { c = 1 } else { c = 0 } document.post.post_mycheckbox.value = c">

Jason Rhinelander
Gossamer Threads
Quote Reply
Re: [Jagerman] Checkbox Question In reply to
Hi Jason,

Thank you for the suggestion.