checkboxes don't submit if empty?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

A friend using my software called me and said some templates were being
reset to default when he submitted a form. I'm trying to track down the
problem. It looks like when he assigns a template to some webpages, any
page not assigned to that template is having its template reset to the
default. I'm not sure why.  I've been assuming that with checkboxes
nothing gets submitted to the server if the checkbox is left unchecked.
Isn't that so?

Sample of the form below. The value equals the id of the webpage. The
template is choosen at the top of the from (that part is not included
here). An array of page ids is built up and submitted to the server, a
PHP script goes throught the array and sets all those pages whose ids
are submitted to the choosen template. None of the other pages should
be effected by this form, yes?


<input type="checkbox" name="formList[]" value="408"> Assign? -
Scholarship -  <a href="index.php?pageId=408">See this page?</a><br />
<input type="checkbox" name="formList[]" value="439"> Assign? - Welcome
from Head of the School -  <a href="index.php?pageId=439">See this
page?</a><br /> <hr><p>
<input type="checkbox" name="formList[]" value="440"> Assign? - Mission
and Philosophy -  <a href="index.php?pageId=440">See this page?</a><br
/> <hr><p>
<input type="checkbox" name="formList[]" value="441"> Assign? - General
Overview /SCHOOL TOUR -  <a href="index.php?pageId=441">See this
page?</a><br /> <hr><p>

<input type="checkbox" name="formList[]" value="442"> Assign? - Faculty
-  <a href="index.php?pageId=442">See this page?</a><br /> <hr><p>
<input type="checkbox" name="formList[]" value="443"> Assign? -
nurturing the whole child -  <a href="index.php?pageId=443">See this
page?</a><br /> <hr><p>
<input type="checkbox" name="formList[]" value="445"> Assign? -
Scholarship -  <a href="index.php?pageId=445">See this page?</a><br />
<input type="checkbox" name="formList[]" value="446"> Assign? - Core
Curriculum -  <a href="index.php?pageId=446">See this page?</a><br />

Re: checkboxes don't submit if empty?

I noticed that Message-ID: contained the following:

Quoted text here. Click to load it

Yes. Only checked values will appear in the array.

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: checkboxes don't submit if empty? wrote:

Quoted text here. Click to load it

This is correct, nothing is submitted.

In the case of your form (snipped), if you had selected eg the ones with
a value of 408, 440 and 441 you would end up with an array called
formList with the values 408, 440 and 441. None of the other checkbox
values would be in this.

Is this form able to edit existing records in the database? If so, are
you doing the correct handling to remove entries that are not

Chris Hope - The Electric Toolbox - /

Re: checkboxes don't submit if empty?

On 3 Feb 2005 16:01:26 -0800, wrote:

Quoted text here. Click to load it
'    Checkboxes (and radio buttons) are on/off switches that may be toggled by
the user. A switch is "on" when the control element's checked attribute is set.
When a form is submitted, only "on" checkbox controls can become successful.'
'17.13.2 Successful controls

A successful control is "valid" for submission. Every successful control has
its control name paired with its current value as part of the submitted form
data set. A successful control must be defined within a FORM element and must
have a control name.'

 So, yes, the assumption is correct according to the specs.

< Space: disk usage analysis tool

Site Timeline