File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes why the checkbox is not check? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "why the checkbox is not check?" Watch "why the checkbox is not check?" New topic

why the checkbox is not check?

Lu Jin

Joined: Feb 22, 2003
Posts: 17
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?


Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60046

What browser are you testing in? Your code worked fine for me in Safari and Firefox.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lu Jin

Joined: Feb 22, 2003
Posts: 17
My browser is IE6
Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

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 ]

[My Blog]
All roads lead to JavaRanch
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
Change your code like this.. this would help you out

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

I agree. Here's the link:
subject: why the checkbox is not check?
Similar Threads
check boxes retrieving problem
How to get value from innerHTML
How to maintain state between different pages in jsp
How to make checkbox checked in display tag