Reputation: 8505
I have something I have to fix asap
In the view I have a hidden checkbox:
<div class="D2">@Html.CheckBox("none", false, new { type="hidden", id = "none" })</div>
//Apply button will submit the form
$('#apply').click(function () {
...
$("#submit").click();
...
});
For some reason it always submits as checked when its hidden. If I remove the hidden property it works just fine. I have to do it this way as its the fastest way to fix the code.
Upvotes: 1
Views: 4916
Reputation: 1512
By passing in type="hidden", you are making it so that the element is no longer a checkbox. It's now a hidden input. Are you trying to get an invisible checkbox? If so try
@Html.CheckBox("none", false, new { id = "none", style="display: none" })
Upvotes: 0
Reputation: 7200
You're not setting a hidden property - you're setting the type property.
I think you want
<input type="checkbox" id="none" style="visibility:hidden;" />
not
<input type="hidden" id="none" />
Try this, instead
@Html.CheckBox("none", false, new { style="visibility:hidden", id = "none" })
Upvotes: 2