Generating checked checkboxes

J

James Carters

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);
}
 
J

Julian Turner

James said:
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
 
J

James Carters

Thanks, perfect

Julian Turner said:
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);
var checked_box = new_checkbox.firstChild;
checked_box.checked = true;
checked_box.onclick=function(){deselectfield(this);}

Regards

Julian
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top