[cfaussie] Re: [OT] javascript checked attribute

2006-06-12 Thread Steve Onnis








Had a bit of a play. Looks like you cant
set the checked property for the checkbox until its been written
to the page like this



var newCheckbox = document.createElement(
input );

newCheckbox.type = checkbox;

newCheckbox.name =
itemToDeploy;

newCheckbox.value = somevalue;


document.body.appendChild(newCheckbox)

newCheckbox.checked = true;



otherwise use a string to create the
checkbox element like this



var newCheckbox =
document.createElement(input type=\Checkbox\
name=\itemToDeploy\ value=\somevalue\ +
(parentListItem.className == inherit ? checked :
) +  )

document.body.appendChild(newCheckbox)



Steve











From: cfaussie@googlegroups.com [mailto:cfaussie@googlegroups.com] On Behalf Of Taco Fleur
Sent: Monday, June 12, 2006 7:12
PM
To: cfaussie@googlegroups.com
Subject: [cfaussie] [OT]
_javascript_ checked attribute







I have the following _javascript_











var newCheckbox =
document.createElement( input );
newCheckbox.type = checkbox;
newCheckbox.name =
itemToDeploy;
newCheckbox.value = fileArray[ i ][ 1 ]; 
if ( parentListItem.className ==
inherit ) {
newCheckbox.checked = true;
}
alert( newCheckbox.checked );






Everything shows up as expected, except that the check box is not
checked, even though alert( newCheckbox.checked ); outputs true...





Does anyone have any idea what could cause this?











Thanks in advance.






-- 
Taco Fleur - http://www.pacificfox.com.au

Web Design, Web development, Graphic Design and Complete Internet Solutions
an industry leader with commercial IT experience since 1994  








--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups cfaussie group.  To post to this group, send email to cfaussie@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cfaussie  -~--~~~~--~~--~--~---






[cfaussie] Re: [OT] javascript checked attribute

2006-06-12 Thread darryl lyons

You can't add the checked attribute after the input has been created,
it must be part of the createElement method.

Try this:

var checked = ;

if ( parentListItem.className == inherit ) {
  checked =  checked;
}

var newCheckbox = document.createElement( input type=checkbox
name=itemToDeploy + checked + );
newCheckbox.value = fileArray[ i ][ 1 ];

Darryl

On 12/06/06, Taco Fleur [EMAIL PROTECTED] wrote:

 I have the following javascript

   var newCheckbox = document.createElement( input );
   newCheckbox.type = checkbox;
   newCheckbox.name = itemToDeploy;
   newCheckbox.value = fileArray[ i ][ 1 ];
   if ( parentListItem.className == inherit ) {
newCheckbox.checked = true;
   }
   alert( newCheckbox.checked );

 Everything shows up as expected, except that the check box is not checked,
 even though alert( newCheckbox.checked ); outputs true...
 Does anyone have any idea what could cause this?

 Thanks in advance.

 --
 Taco Fleur - http://www.pacificfox.com.au
 Web Design, Web development, Graphic Design and Complete Internet Solutions
 an industry leader with commercial IT experience since 1994 …
  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
cfaussie group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~--~~~~--~~--~--~---