If (acctRB.Checked == true)
{
Execute Business Code
}
views:
46answers:
2
A:
Well, you don't need the == true:
if (acctRB.checked)
{
// It's checked
}
else
{
// It's not checked
}
So what you have is pretty much correct. Just remove the == true as it's not required.
GenericTypeTea
2010-10-01 13:49:36
if document.getElementById('acctRB').checked == true){ alert('hi'); }
bill
2010-10-01 13:52:25
ok wil try that
bill
2010-10-01 13:54:08
hmm idk why this isnt' workign
bill
2010-10-01 13:55:12
You're missing a bracket: `if (document.getElementById('acctRB').checked){ alert('hi'); }`. Here's a working example: http://jsfiddle.net/WRHAn/
GenericTypeTea
2010-10-01 13:56:41
A:
Bear in mind that IE is case insensitive while other browsers aren't. Your sample code will work for IE....
Rather do
if (acctRB.checked) {
//Checked
} else {
//Unchecked
}
It works for both IE and other major browsers....Or, if if checkbox id is "acctRB" do,
if (document.getElementById("acctRB").checked) {
//Checked
} else {
//Unchecked
}
The Elite Gentleman
2010-10-01 14:00:25