putha
10-13-2011, 05:24 PM
I am trying to make a simple alert come up stating a checkbox is checked when it changes, and then another alert for when the checkbox is unchecked.
Problem is, only the alert for when the box is checked is coming up.
Anyone know why?
function displayCheckPopUp()
{
if(document.activeElement.checked=true)
{
alert("A check box has been selected");
}
else if(document.activeElement.checked=false)<!--if(document.getElementById().checked=false)-->
{
alert("****");
}
}
<input type="checkbox" name="Checkbox 1" value="Checkbox 1" id="first_cbox" onchange="displayCheckPopUp(this)" /> <p class="custom_style2"> Checkbox 1 </p>
Problem is, only the alert for when the box is checked is coming up.
Anyone know why?
function displayCheckPopUp()
{
if(document.activeElement.checked=true)
{
alert("A check box has been selected");
}
else if(document.activeElement.checked=false)<!--if(document.getElementById().checked=false)-->
{
alert("****");
}
}
<input type="checkbox" name="Checkbox 1" value="Checkbox 1" id="first_cbox" onchange="displayCheckPopUp(this)" /> <p class="custom_style2"> Checkbox 1 </p>