Unfortunately all is not simple in browser-land. You can use checked
with no values, or checked="checked" or checked="true|false" and get
what you want/expect given a particular doctype. Even coding to XHTML
standards doesn't mean the browser will follow the standards, since
most XHTML is rendered as HTML(ish). Browsers are notoriously
forgiving, to the detriment of everyone :(

Your best bet is to try and follow specs in the hope that you're
building in forwards-compatibility as user-agents become more
standards compliant.

On Feb 12, 9:27 am, Frederik Ring <frederik.r...@gmail.com> wrote:
> Well thanks for that, I didn't know and it seems to work perfectly
> But why is it then when I do something like an alert($(mycheckbox).attr
> ('checked')); on an unckecked checkbox it returns false?
>
> On Feb 12, 5:46 pm, mkmanning <michaell...@gmail.com> wrote:
>
> > In HTML checked is a boolean (of sorts), its presence is sufficient,
> > you don't need to set it to anything; if you want something unchecked
> > you should remove the 'checked' attribute. In XHTML, attribute
> > minimization is forbidden (i.e. attributes can't be empty), so the
> > proper syntax is checked="checked" (for disabled it's
> > disabled="disabled", etc.)
>
> > Use removeAttr() instead of setting the value to false.
>
> > On Feb 12, 8:26 am, Frederik Ring <frederik.r...@gmail.com> wrote:
>
> > > Hi!
>
> > > The thing is that somwhow (don't ask me why) the unchecked attribute
> > > of a checkbox is '' instead of 'false'.
>
> > > This worked fine with me:
> > > HTML:
> > > <input class="parentcheckbox" type="checkbox" checked="true"
> > > name="cb01"></input>
> > > <input class="childcheckbox" type="checkbox" checked="true"
> > > name="cb02"></input>
> > > <input class="childcheckbox" type="checkbox" checked="true"
> > > name="cb03"></input>
> > > <input class="childcheckbox" type="checkbox" checked="true"
> > > name="cb04"></input>
>
> > > jQuery:
> > > $(document).ready(function(){
> > >         $('.childcheckbox').change(function(){
> > >                 $(this).prev('.parentcheckbox').attr('checked','');
> > >         });
>
> > > });
>
> > > On Feb 12, 4:57 pm, Andy <adharb...@gmail.com> wrote:
>
> > > > Hey guys,
>
> > > > I'm trying to uncheck a checkbox that is inside my flexigrid.  I have
> > > > a checkbox in the header and the column has all checkboxes.  What I'm
> > > > trying to do is if I select the top checkbox (so all of the checkboxes
> > > > below are selected), I would like to uncheck that checkbox if any of
> > > > the other checkboxes in that column are unchecked.
>
> > > > I'm using the following code, but when it runs through this, it
> > > > unselects all of the items, instead of just the header.
>
> > > > Code snippet:
> > > > ================================================================
> > > > var rItem = document.getElementById("chk_col_" + colName);
> > > > $("inp...@name=" + rItem.name + "][type='checkbox']").attr('checked',
> > > > false);
> > > > ================================================================
>
> > > > The checkbox is named correctly, so I'm not sure why this isn't
> > > > working.
>
> > > > Thanks!

Reply via email to