Closed Bug 121202 Opened 23 years ago Closed 23 years ago

Can't set 'checked' property of <Input type=checkbox > while loading a page

Categories

(Core :: Layout: Form Controls, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Maniac, Assigned: john)

References

()

Details

First look into the source of the URL - it's self-explanatory.
Here goes a description:
The page creates a form with 3 checkboxes. Then inline JavaScript tries to set
each checkbox' 'checked' to 'true' and fails.
After 3 seconds the same JavaScript code is called again (through setTimeout)
and works good.

P.S. When I insert, say, window.alert(elements[i]) before setting 'checked' the
code works good for the first time too.
Component: Form Manager → HTML Form Controls
Reassigning
Assignee: morse → rods
QA Contact: tpreston → madhur
confirming on linux 2002-01-19-21.  jkeiser?
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 2000 → All
Hardware: PC → All
The problem is probably that the frame doesn't exist yet.  Pretty sure this will
go away with bug 108308.
Depends on: 108308
->>
Assignee: rods → jkeiser
Interesting note: if I use elements[i].setAttribute('checked') instead of
setting directly elements[i].checked=true everything works.

Does Mozilla use different APIs for accessing a property directly or through a
DOM method?
.checked and setAttribute("checked") do entirely different things.  One sets an
attribute on a node (equivalent to actually editing the HTML).  The other
changes the value of a DOM property.  The fact that the initial value of the DOM
property is decided based on the value of the attribute is the only thing that
ties the two together.
Thanks for explanation.

My misunderstanding was because I've seen the .checked property on a W3C in the
DOM1 spec. I did think that setting properties through setAttribute or
propertie's  corresponding interface should differ just in syntax... Now I see
the true difference :-)
Oops, I set the dependency wrong before, it was bug 108307, which has landed,
and fixed this bug with it.
Status: NEW → RESOLVED
Closed: 23 years ago
Depends on: 108307
No longer depends on: 108308
Resolution: --- → FIXED
QA Contact: madhur → tpreston
You need to log in before you can comment on or make changes to this bug.