Checkbox changed by browser after running javascript

N

NnlGggTuqPvt

I have a form with a checkbox. Using MSIE, the user marks the checkbox,
submits the form and gets his result. Then he uses the browsers back
button to return to the form.

Here I have a
checkbox=document.getElementById('ch1');
alert(checkbox.status);

This alert pops up and says "false". I can see that the checkbox is not
activated. Then I click "ok" to the alert and then the checkbox is
checked. I.e. the browser fills in the previous values _after_
javascript processing is done.
How can I determine the checkbox status with javascript?

JMS
 
R

RobG

I have a form with a checkbox. Using MSIE, the user marks the checkbox,
submits the form and gets his result. Then he uses the browsers back
button to return to the form.

Here I have a
checkbox=document.getElementById('ch1');
alert(checkbox.status);

This alert pops up and says "false".

When do you activate the above script - onload? in a script element in
the page?


I can see that the checkbox is not
activated. Then I click "ok" to the alert and then the checkbox is
checked. I.e. the browser fills in the previous values _after_
javascript processing is done.
How can I determine the checkbox status with javascript?

When - onload? during load?
 
K

knocte

(e-mail address removed) escribió:
I have a form with a checkbox. Using MSIE, the user marks the checkbox,
submits the form and gets his result. Then he uses the browsers back
button to return to the form.

Here I have a
checkbox=document.getElementById('ch1');
alert(checkbox.status);

This alert pops up and says "false". I can see that the checkbox is not
activated. Then I click "ok" to the alert and then the checkbox is
checked. I.e. the browser fills in the previous values _after_
javascript processing is done.
How can I determine the checkbox status with javascript?

JMS

I didn't ever hear about a "status" property. Why don't you use "checked"?

Andrew [ knocte ]

--
 
N

NnlGggTuqPvt

When do you activate the above script - onload? in a script element in
the page?

Of course I don't check it onload, the script is inside the page
between </body> and </html>

JMS
 
R

RobG

Of course I don't check it onload,

Why not? It will likely fix your problem.

the script is inside the page
between </body> and </html>

That is invalid markup, an HTML element can only contain head and body
elements:

<!ENTITY % html.content "HEAD, BODY">

<URL:http://www.w3.org/TR/html4/struct/global.html#edef-HTML>


If the browser stumbles across a script element as a child of the HTML
element, you are at the mercy of error correction.
 
N

NnlGggTuqPvt

I didn't ever hear about a "status" property. Why don't you use "checked"?

I think it's not important what I use. When the alert pops up, the
checkbox is not checked. The browser fills the check mark after the
script ran.

JMS
 
L

Lee

(e-mail address removed) said:
Of course I don't check it onload, the script is inside the page
between </body> and </html>

Judging by the fact that "of course I don't" is not a reasonable answer,
I'm guessing that you don't understand that "onload" means using the
body's onLoad event handler, so that the code is executed after the page
has completely loaded.

Code appearing after the body is invalid HTML.
 

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
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top