Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why the checkbox is not check?

 
Lu Jin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the following code to generate a checkbox and want to set it to checked. but it's not checked after loaded, anybody can tell me the reason?

thanks!

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What browser are you testing in? Your code worked fine for me in Safari and Firefox.
 
Lu Jin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My browser is IE6
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the "data" element ? And when are you calling init()?

(by the way, it worked for me too)
[ November 13, 2006: Message edited by: Satou kurinosuke ]
 
Krishna Nagadev
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change your code like this.. this would help you out

function init()
{
var input = document.createElement("input");
input.type = "checkbox";
input.id = "test";
input.name = "test";

document.getElementById("data").appendChild(input);
document.getElementById('test').checked=true;
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic