[Proto-Scripty] Re: Form.serialize and unchecked checkboxes

2010-08-03 Thread RobG


On Jul 31, 3:56 am, strimp099  wrote:
> Greetings all:
>
> When sending form variables as a hash using Form.serialize(true), the
> value attribute of unchecked checkboxes is sent to the POST page. This
> of course is contrary to how HTML treats checkbox form variables.
>
> for example, I have the following checkboxes:
>
>  checked="checked" />
>  id="constructor" checked="checked" />

Note that both checkboxes have the checked attribute which means, in
standards compliant browsers, that their checked attribute will always
return "checked" until set to some other value. Their checked property
will return boolean true or false depending on whether the control is
checked or not.

IE is not standards compliant in this regard. It returns boolean true
or false for both property and attribute depending on whether the
control is checked or not (respectively). See below.


> I only want destructor and constructor to be passed as true if the
> checkbox is checked. Form.serialize(true) sends the true value even
> when it is not checked.

As far as I can tell, Prototype.js uses the checked property so it
should get it right.

For fun, try the following in various browsers and compare results:


  

   



--
Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: Form.serialize and unchecked checkboxes

2010-08-01 Thread T.J. Crowder
Hi,

> Form.serialize(true) sends the true value even
> when it is not checked.

Not in my experience:
http://jsbin.com/uxiko4

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

On Jul 30, 6:56 pm, strimp099  wrote:
> Greetings all:
>
> When sending form variables as a hash using Form.serialize(true), the
> value attribute of unchecked checkboxes is sent to the POST page. This
> of course is contrary to how HTML treats checkbox form variables.
>
> for example, I have the following checkboxes:
>
>  checked="checked" />
>  id="constructor" checked="checked" />
>
> I only want destructor and constructor to be passed as true if the
> checkbox is checked. Form.serialize(true) sends the true value even
> when it is not checked.
>
> Does anyone know how to ensure that if a checkbox is not checked, the
> value attribute will not be sent when using Form.serialize()?

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.