ck my checkbox input

M

mike

I am dynamically creating an input that is a checkbox like:

myINPUT = document.createElement("INPUT");
myINPUT.type = "checkbox";
myINPUT.id = myINPUT.name = "myck_box";
myINPUT.value = "Y";
myINPUT.checked = true;
myINPUT.disabled = true;
 
M

mike

I see .... I have to check it after I create it, i.e. I can't create it
in the "checked" condition.

Thanks, let me try that
 
F

Fred Oz

mike said:
I see .... I have to check it after I create it, i.e. I can't create it
in the "checked" condition.

No, for IE you have to check it after you *add it to the document*,
Firefox is quite happy for you to check it anytime after it is
created.

Until the checkbox is added to the document (either by appending it
to an element that is part of the document, or adding its parent
element to the document), IE will not check it.

In either case you must create it first before you can do anything
with it - I suspect that will be true of all browsers.
Thanks, let me try that

Ok.
 
D

Dietmar Meier

mike said:
I see .... I have to check it after I create it, i.e. I can't create
it in the "checked" condition.

You can. When the checkbox is added to the document (or when the
document is (re)loaded or the form reset), its "defaultChecked"
property determines its initial checked status.

myINPUT = document.createElement("INPUT");
myINPUT.type = "checkbox";
myINPUT.id = myINPUT.name = "myck_box";
myINPUT.value = "Y";
myINPUT.defaultChecked = true;
myINPUT.disabled = true;

ciao, dhgm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top