Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #24263 > unrolled thread

Why checkbox field is not detected when the form is submitted?

Started byjustaguy <lichunshen84@gmail.com>
First post2014-05-19 12:41 -0700
Last post2014-05-20 10:19 +0000
Articles 6 — 5 participants

Back to article view | Back to comp.lang.javascript


Contents

  Why checkbox field is not detected when the form is submitted? justaguy <lichunshen84@gmail.com> - 2014-05-19 12:41 -0700
    Re: Why checkbox field is not detected when the form is submitted? justaguy <lichunshen84@gmail.com> - 2014-05-19 13:01 -0700
      Re: Why checkbox field is not detected when the form is submitted? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-19 23:55 +0200
    Re: Why checkbox field is not detected when the form is submitted? dhtml <dhtmlkitchen@gmail.com> - 2014-05-19 16:42 -0700
    Re: Why checkbox field is not detected when the form is submitted? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-05-20 07:56 +0300
    Re: Why checkbox field is not detected when the form is submitted? Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-20 10:19 +0000

#24263 — Why checkbox field is not detected when the form is submitted?

Fromjustaguy <lichunshen84@gmail.com>
Date2014-05-19 12:41 -0700
SubjectWhy checkbox field is not detected when the form is submitted?
Message-ID<149e228b-45da-4203-a4b9-6a01b089f257@googlegroups.com>
The following fiddle js code for ON and OFF switch is very cool, however, the checkbox field is not included the FORM when it is submited, how come?

Please note, I've added name and value attributes to this checkbox.  When the form is submitted and when checkbox is set to OFF then the field and its value shows up in the FORM submission, hmm...

http://jsfiddle.net/boweruk/DMfvx/7/


Thanks in advance.

[toc] | [next] | [standalone]


#24264

Fromjustaguy <lichunshen84@gmail.com>
Date2014-05-19 13:01 -0700
Message-ID<1e13d025-faee-46c1-a563-5b9c28a3d102@googlegroups.com>
In reply to#24263
On Monday, May 19, 2014 3:41:28 PM UTC-4, justaguy wrote:
> The following fiddle js code for ON and OFF switch is very cool, however, the checkbox field is not included the FORM when it is submited, how come?
> 
> 
> 
> Please note, I've added name and value attributes to this checkbox.  When the form is submitted and when checkbox is set to OFF then the field and its value shows up in the FORM submission, hmm...
> 

Ok, upon reading of the entire code, I noticed that the following code block may explain why the ON state does not pass the field to the FORM:
"
input:checked::after {
    left: 0;
}
"

So, now, the revised question, how could we make either STATE (on / off) send the field and its value for FORM submission?

Thanks.

[toc] | [prev] | [next] | [standalone]


#24266

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2014-05-19 23:55 +0200
Message-ID<XnsA332F35DF7472eejj99@194.109.133.133>
In reply to#24264
justaguy <lichunshen84@gmail.com> wrote on 19 mei 2014 in 
comp.lang.javascript:

> input:checked::after {
>     left: 0;
>}
> "

This NG is about javascript,
the above is CSS.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#24270

Fromdhtml <dhtmlkitchen@gmail.com>
Date2014-05-19 16:42 -0700
Message-ID<3baa58a0-d855-44c7-bb41-065ad6ea2f8e@googlegroups.com>
In reply to#24263
On Monday, May 19, 2014 12:41:28 PM UTC-7, justaguy wrote:
> The following fiddle js code for ON and OFF switch is very cool, however, the checkbox field is not included the FORM when it is submited, how come?
> 

Who wrote this code?


Try using a checkbox without any CSS. And see what happens. Then, add CSS. 

I'm NOT going to answer this question for you.

> 
> Please note, I've added name and value attributes to this checkbox.  When the form is submitted and when checkbox is set to OFF then the field and its value shows up in the FORM submission, hmm...
> 

And that is exactly what the code is asking for. 

> 
> http://jsfiddle.net/boweruk/DMfvx/7/
> 
> 
> 
> 
> 
> Thanks in advance.

That's neat. But the appearance property was removed from CSS3.

http://www.w3.org/wiki/User:Tantekelik/CR-css3-ui-20040511-appearance

Whether or not the form is successful wasn't determined in the abandoned property. 

[toc] | [prev] | [next] | [standalone]


#24272

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2014-05-20 07:56 +0300
Message-ID<llena0$e0i$1@dont-email.me>
In reply to#24263
2014-05-19 22:41, justaguy wrote:

> The following fiddle js code for ON and OFF switch is very cool,
> however, the checkbox field is not included the FORM when it is
> submited, how come?

Because it has no name attribute. Oh, and because the form can never be 
submitted when using the code in the jsfiddle: there is no submit button 
and not even any <form> element.

> Please note, I've added name and value attributes to this checkbox.

Not in the jsfiddle.

> When the form is submitted and when checkbox is set to OFF then the
> field and its value shows up in the FORM submission, hmm...
>
> http://jsfiddle.net/boweruk/DMfvx/7/

I don't think they do. If you add a `name` attribute to the `input` 
element, and if you add a <form> element and an input button, then a 
name=value pair is included in the form data upon submission when the 
checkbox is checked, not otherwise. The CSS code does not affect this; 
this is just how HTML elements are handled.

The code does not contain any JavaScript, so I'm assuming you are asking 
how to fix the problem with JavaScript. The short answer is that you 
could add a hidden field into the form and set its value according to 
the checkbox setting. But this would be pointless in most contexts. 
Checkboxes are supposed to work so that name=value is included when the 
checkbox is on, not otherwise. Form handling, client-side and 
server-side, should be written to work with this (on the server, just 
check for the existence of a field with the name; you can check the 
value too, but that would be just data integrity check) rather than work 
around it.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#24275

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-05-20 10:19 +0000
Message-ID<llfa7u$8b0$4@dont-email.me>
In reply to#24263
On Mon, 19 May 2014 12:41:28 -0700, justaguy wrote:

> The following fiddle js code for ON and OFF switch is very cool,
> however, the checkbox field is not included the FORM when it is
> submited, how come?

Is the checkbox inside the form? Does the checkbox have a name attribute? 
Is the checkbox checked? What does any of this have to do with javascript?

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web