Answered
Reading checked state of checkbox
Hi there:-
'Sorry to post such a simple question but I can find the answer in the Dreamweaver online reference, and I have wasted a lot of time trying to find the answer.
I want to read the checked state of a given checkbox and then if value of true is returned invoke function "A" or if false is returned invoke function "B".
Based on what I found in the reference I set up a variable to capture the state of the checkbox as follows:
function checkboxState()
{
var checkState = document.all.nameOfCheckbox.checked;
if (checkState == true)
{
statements
}
else
if (checkState == false)
{
statements
}
}
The check box is setup as follows:
<input name="nameOfCheckbox" type="checkbox" onClick="checkboxState()">
This doesn't work and I don't know why. I wondered if I had to define the checkbox in a particular way, e.g. using the value attribute or something, but the reference did not indicate this.
If anyone can help I would appreciate it.
Thanks!
'Sorry to post such a simple question but I can find the answer in the Dreamweaver online reference, and I have wasted a lot of time trying to find the answer.
I want to read the checked state of a given checkbox and then if value of true is returned invoke function "A" or if false is returned invoke function "B".
Based on what I found in the reference I set up a variable to capture the state of the checkbox as follows:
function checkboxState()
{
var checkState = document.all.nameOfCheckbox.checked;
if (checkState == true)
{
statements
}
else
if (checkState == false)
{
statements
}
}
The check box is setup as follows:
<input name="nameOfCheckbox" type="checkbox" onClick="checkboxState()">
This doesn't work and I don't know why. I wondered if I had to define the checkbox in a particular way, e.g. using the value attribute or something, but the reference did not indicate this.
If anyone can help I would appreciate it.
Thanks!
