I am trying to check weather a checkbox is checked or unchecked. This is my code:
<script type="text/javascript">
function EnableDisableToolTip() {
if (document.forms[0].help_text.checked) {
alert("Checked");
}
else if (!document.forms[0].help_text.checked) {
alert("Unchecked");
}
}
</script>
<div id="tooltiponoff">
<form action="">
@Html.CheckBox("help_text", true, new { id = "help_text", onclick = "EnableDisableToolTip()" })Hjælpetekst
</form>
</div>
It only alerts Unchecked when i click it
Thanks in advance
alert(document.forms[0].help_text)gives.. ? May be if undefined, it would always go in else condition..