Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Generating checked checkboxes

Reply
Thread Tools

Generating checked checkboxes

 
 
James Carters
Guest
Posts: n/a
 
      11-29-2005
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);
}


 
Reply With Quote
 
 
 
 
Julian Turner
Guest
Posts: n/a
 
      11-29-2005

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

 
Reply With Quote
 
 
 
 
James Carters
Guest
Posts: n/a
 
      11-29-2005
Thanks, perfect

"Julian Turner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckBox Checked=false when checked in DataList yurps ASP .Net 1 02-29-2008 01:08 PM
Determine Which Checkboxes are Checked Wayne Wengert ASP .Net 2 02-05-2006 02:25 PM
CheckBoxes in DataGrids-- the "checked" attribute not correct after posting page? Jim Bancroft ASP .Net 4 08-04-2005 04:19 PM
How to allow only one checkbox to be checked in a group of checkboxes moondaddy ASP .Net 4 06-22-2004 04:32 AM
Checkboxes checked in runtime datagrid DJ Dev ASP .Net 7 02-10-2004 05:41 PM



Advertisments