Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "why the checkbox is not check?" Watch "why the checkbox is not check?" New topic
Author

why the checkbox is not check?

Lu Jin
Greenhorn

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?

thanks!



SCJP, SCWCD, SCBCD, OCA, Next-->SCEA
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60781
    
  65

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
Greenhorn

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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";
input.id = "test";
input.name = "test";

document.getElementById("data").appendChild(input);
document.getElementById('test').checked=true;
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why the checkbox is not check?
 
Similar Threads
How to get value from innerHTML
Checkbox
How to make checkbox checked in display tag
How to maintain state between different pages in jsp
check boxes retrieving problem