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: [email protected] [mailto:[email protected]] On Behalf Of Taco Fleur
Sent: Monday, June 12, 2006 7:12 PM
To: [email protected]
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---

Reply via email to