Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Understanding Checkboxes

Quote Reply
Understanding Checkboxes
I've been trying to get Checkboxes to work the way I want but can't seem to. What I would like is a checkbox that is either On or Off so that a checkbox named [X]Box would print Box on the page when built using the <%Box%> tag, but when unchecked [ ]Box the value in the field would be NULL.
This works when the field is empty and I check the box, but when I uncheck the box on Modify, it doesn't NULL out the field but leaves the value Box.
I've tried values of Box and "", Box and nothing,
for both Form Names and Form Values. I've tried INT fields, Text Fields, etc.
I could always put a radio button called Box with a Yes or No button, but unchecking a checkbox should be able to work and looks better.

What am I doing wrong?

Quote Reply
Re: Understanding Checkboxes In reply to
I should clarify that I'm changing the record in the Admin Tool, but unchecking the Checkbox does not remove the value from the field.

Quote Reply
Re: Understanding Checkboxes In reply to
Shouldn't unchecking a checkbox remove the value from the database?


Quote Reply
Re: Understanding Checkboxes In reply to
Hi,

I don't think you will be able to do this. The reason is how checkboxes work on forms. If you have a checkbox called 'enabled' with a value of 'Yes', when you submit the form, the browser sends enabled=Yes to the script. However, if it's not checked, then nothing is sent. This is different then with text fields, as normally you would get enabled=(nothing).

The program thinks you haven't submitted this field, and so it is not updated. It would not be easy to change this without breaking a lot of other code.

For now, I would use a radio button Yes|No.

Cheers,

Alex

--
Gossamer Threads Inc.