HTML checkboxes are ILLOGICAL
When you submit an html form you get a $_REQUEST array and in almost every case there are exactly as many elements in the array as there are elements on the form.
This goes for textboxes. selects, textareas, hidden elements and probably more kinds as well if there are any.
Each element has a "name" attribute and when you submit the form the name of the element becomes a key in the $_REQUEST array and the value you have put in the element becomes the value associated with that key.
With checkboxes it is COMPLETELY DIFFERENT.
If the box is unticked I would expect 0 or False to be passed into $_REQUEST along with the name of the checkbox as its key. But actually NOTHING is passed - no value, and no key either.
It really upsets me that when you look at $_REQUEST it will have exactly one element for each element on the form (including hidden ones) EXCEPT FOR CHECKBOXES in which case the NUMBER OF ELEMENTS IN $_REQUEST will DEPEND ON WHAT VALUES YOU ENTERED INTO THE FORM ! !! !! !! !! !!
If anyone has a defence of that as being logical behaviour I would be interested to read it. At the moment I think that people who make language design decisions like that should not be allowed near a computer.
This is not a defense, this is an observation.
Too often in our lives we will come to the exact same striking checkbox realization. I had once succeed to be almost a happy man among happy people. But despite my "luck" for being at the right time, in the right place with the right people, something was still wrong and I could not figure what it was. Today when I look back on my past as an aspie without knowing it, the more I discover asperger through me, the more it explains me, the more I see myself under a new light. Totally new things appear, but these things were in fact always there, right?
These past weeks, I realized I did a lot of mistakes at very specific moments of my life. Nevertheless, as I turn these past events in every possible direction I keep coming to the same single one conclusion: I was not wrong, these are not "mistakes", they were completely thought out, coherent with the context and integrated in the flow. I have no guilt, I don't feel sorry
So two possibilities here:
- Either we, aspies are completely wrong and there is no meaning or harmony outside
- Either we are right and there is a proper order or unity to things
Everything in my life could be summarized to these f***ing checkboxes
_________________
I came, I saw, I conquered, now I want to leave
Forgetting to visit the chat is a capital Aspie sin: http://www.wrongplanet.net/asperger.html?name=ChatRoom
It's not that I don't understand how it works - rather, I disagree with it.
Its behaviour is not only diffferent from other controls - it is different in a LOGICALLY SIGNIFICANT way.
You can see the rest of the controls as key-value pairs - the "name" being the key, and what you've put in the control becoming the value. So what you need to ask when you process the data server-side is: "What is the value for this key"? For the checkbox the corresponding question is: "Does this key exist at all?"
From a logical point of view that is a fundamental difference.
Do you mean that different browsers will post different things? Surely that can't be right. That would be a serious problem for server-side code.
Yes, different browsers could post different things and both could still be following the HTML spec (e.g. one could post control1=value&control2=&control3=anothervalue and one could post control1=value&control3=anothervalue). Your server side code should take this into account.
See: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2. "If a control doesn't have a current value when the form is submitted, user agents are not required to treat it as a successful control."
Thanks, I didn't know that! I will certainly take that into account in future code.
It also helps me put into clearer words what exactly my issue is with the checkboxes. It seems a checkbox is treated as not having a value if it is not checked. But I see them as being a way to choose between two values. I come from a database background and I think of a checkbox as corresponding to a database field of type boolean ( or bit or tinyint(1) depending on sql flavour).
Thanks for taking the time to explain but I still disagree with the standard (insofar as the standard implies that an unchecked checkbox has no value).
