Generating checked checkboxes

Discussion in 'Javascript' started by James Carters, Nov 29, 2005.

  1. Have a long scrolling list of checkboxes and I want to move the checked
    checkboxes into an adjacent div, works on firefox, but ie wont let them be
    checked, is this doable? Failing that does anyone know of a way to do this
    with multiselects without requiring ctrl click?

    function selectfield(o){
    var checked_owner_container =
    document.getElementById('checked_owner_container');
    var row = o.parentNode;
    var new_checkbox = row.cloneNode(true);
    var checked_box = new_checkbox.firstChild;
    checked_box.checked = true;
    checked_box.onclick=function(){deselectfield(this);}
    checked_owner_container.appendChild(new_checkbox);
    }
     
    James Carters, Nov 29, 2005
    #1
    1. Advertising

  2. James Carters wrote:

    > Have a long scrolling list of checkboxes and I want to move the checked
    > checkboxes into an adjacent div, works on firefox, but ie wont let them be
    > checked, is this doable? Failing that does anyone know of a way to do this
    > with multiselects without requiring ctrl click?
    >
    > function selectfield(o){
    > var checked_owner_container =
    > document.getElementById('checked_owner_container');
    > var row = o.parentNode;
    > var new_checkbox = row.cloneNode(true);
    > var checked_box = new_checkbox.firstChild;
    > checked_box.checked = true;
    > checked_box.onclick=function(){deselectfield(this);}
    > checked_owner_container.appendChild(new_checkbox);
    > }


    AFAIK, IE does not let you set the checked property until the element
    has been added to the document tree.

    Try re-ordering your code by appending earlier:-

    var new_checkbox = row.cloneNode(true);
    > checked_owner_container.appendChild(new_checkbox);

    var checked_box = new_checkbox.firstChild;
    checked_box.checked = true;
    checked_box.onclick=function(){deselectfield(this);}

    Regards

    Julian
     
    Julian Turner, Nov 29, 2005
    #2
    1. Advertising

  3. Thanks, perfect

    "Julian Turner" <> wrote in message
    news:...
    >
    > James Carters wrote:
    >
    > > Have a long scrolling list of checkboxes and I want to move the checked
    > > checkboxes into an adjacent div, works on firefox, but ie wont let them

    be
    > > checked, is this doable? Failing that does anyone know of a way to do

    this
    > > with multiselects without requiring ctrl click?
    > >
    > > function selectfield(o){
    > > var checked_owner_container =
    > > document.getElementById('checked_owner_container');
    > > var row = o.parentNode;
    > > var new_checkbox = row.cloneNode(true);
    > > var checked_box = new_checkbox.firstChild;
    > > checked_box.checked = true;
    > > checked_box.onclick=function(){deselectfield(this);}
    > > checked_owner_container.appendChild(new_checkbox);
    > > }

    >
    > AFAIK, IE does not let you set the checked property until the element
    > has been added to the document tree.
    >
    > Try re-ordering your code by appending earlier:-
    >
    > var new_checkbox = row.cloneNode(true);
    > > checked_owner_container.appendChild(new_checkbox);

    > var checked_box = new_checkbox.firstChild;
    > checked_box.checked = true;
    > checked_box.onclick=function(){deselectfield(this);}
    >
    > Regards
    >
    > Julian
    >
     
    James Carters, Nov 29, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    7
    Views:
    694
    DJ Dev
    Feb 10, 2004
  2. moondaddy
    Replies:
    4
    Views:
    109,345
    TN Bella
    Jun 22, 2004
  3. yurps
    Replies:
    1
    Views:
    6,965
    rajeshthangarasu1983
    Feb 29, 2008
  4. Jim Bancroft
    Replies:
    4
    Views:
    886
  5. Wayne Wengert

    Determine Which Checkboxes are Checked

    Wayne Wengert, Feb 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,930
    Wayne Wengert
    Feb 5, 2006
Loading...

Share This Page