[英]mvc .net form submit checkbox-label not working in Internet Explorer
In my .NET MVC application I have a form. 在我的.NET MVC应用程序中,我有一个表格。 This form contains a checkbox with label.
此表单包含带有标签的复选框。 If this is pushed, it triggers a controller-method that updates a DB-value (true/false)
如果推送此消息,它将触发更新DB值的控制器方法(是/否)
Everything works fine in chrome. 一切都可以在Chrome中正常运行。 In IE, it only works when clicking the checkbox, not its label.
在IE中,它仅在单击复选框而不是其标签时才起作用。
<form class="form-horizontal" method="POST"
action="/Cards/UpdateCard">
//(Other labels that is not editable)
<div class="col-xs-12 col-md-3 checkbox">
<label onclick=" this.form.submit(); " id="xs-lighter">
@if (paymentCard.AutomaticEmailEnabled)
{
<input class="" type="checkbox" name="SelectedSources" checked="checked" onclick=" this.form.submit(); ">
}
else
{
<input class="" type="checkbox" name="SelectedSources" onclick=" this.form.submit(); ">
}
Automatic send mail
</label>
</div>
</form>
How can I change this to work in both Chrome and IE? 如何更改此设置使其在Chrome和IE中都可以使用?
Try this out with jquery 用jQuery尝试一下
$('#xs-lighter').click(function() {
$("#form1").submit();
});
<form class="form-horizontal" method="POST"
action="/MyCards/UpdatePaymentcard" id="form1">
//(Other labels that is not editable)
<div class="col-xs-12 col-md-3 checkbox">
<label id="xs-lighter">
@if (paymentCard.AutomaticEmailEnabled)
{
<input class="" type="checkbox" name="SelectedSources" checked="checked" onclick=" this.form.submit(); ">
}
else
{
<input class="" type="checkbox" name="SelectedSources" onclick=" this.form.submit(); ">
}
Automatic send mail
</label>
</div>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.