Here's a test case:

http://sosaladesign.com/checkboxTestCase/

Try it on the browser of your heart.

I tested it on Safari 4 Beta (OSX), FireFox 3 (OSX), and IE7 (XP).
All passed with serious tenacity.  Whatchoo talkin' about willis?

On Mar 17, 12:18 pm, Vittorio <vittorio.zampare...@gmail.com> wrote:
> Sorry I forgot to enumerate set('checked', true), but I already tested
> it.
> It's neat and works for setting the state on firefox3, but it doesn't
> work on IE7 (at all) and it doesn't set the "default" state (the one
> the checkbox returns when RESET is clicked).
>
> I did other tests: setAttribute changes the DOM in ff and IE7 BUT in
> IE7 the attribute is not respected when RESET is clicked (checboxes
> get off)
>
> Thank you
> any other idea?
>
> PS Simple html markup (not js generated) works flawlessly as expected
>
> On Mar 17, 6:59 pm, Fábio Costa <fabiomco...@gmail.com> wrote:
>
> > $('mycheckbox').set('checked', true);
>
> > is the 'correct' way, or maybe the mootools way.
>
> > Fábio Miranda Costa
> > Engenheiro de Computaçãohttp://meiocodigo.com
>
> > On Tue, Mar 17, 2009 at 2:54 PM, Vittorio 
> > <vittorio.zampare...@gmail.com>wrote:
>
> > > I already post a teaser to this question, and now I'm going to fully
> > > explain.
>
> > > I'm creating controls in a form dinamically, and I want to set their
> > > initial state.
> > > In particular checkboxes:
>
> > > $('mycheckbox').checked=true; // I don't like this, breaks simmetry
> > > with the rest of the code
>
> > > $('mycheckbox').set('checked','checked');
>
> > > $('mycheckbox').setProperty('checked','checked');
>
> > > $('mycheckbox').setAttribute('checked','checked'); //works the best,
> > > but why?
>
> > > Didn't try the first, but have no reason not to think it works. So
> > > let's say we have FOUR ways of setting a checkbox state (unfortunate
> > > html creators: value should be a boolean, but is an optional string)
>
> > > BUT only the fourth - setAttribute - works fine with RESET buttons.
> > > All other sets "visually" the state of the checkbox, but  don't change
> > > the DOM (inspecting it with fb) and when RESET is pushed the checkbox
> > > revert to unchecked.
>
> > > Has anyone the insight of this mechanism? Can he/she explain? How
> > > shall we code an plan about this issue?
>
> > > Thank you
>
> > > PS I know it's not the place but I want to tell you a trick I
> > > "invented" with checkboxes (receving data in php - where "0" string is
> > > falsy).
>
> > > To always have a value wether true or false I used to:
> > > <input type="hidden" name="thefieldname" value="0">
> > > <label>A checkbox
> > > <input type="checkbox" name="thefieldname" value="1">
> > > </label>
> > > eventually putting checked="checked" where it belonged.
>
> > > It happens somehow that the second checkbox, if chosen, overwrites the
> > > first.
>
> > > Maybe this could be implemented in a plugin for mootools, to
> > > "standardize" the way checkboxes are used.
> > > Thank you- Hide quoted text -
>
> > - Show quoted text -

Reply via email to