简体   繁体   English

MVC .NET表单提交复选框标签在Internet Explorer中不起作用

[英]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.

相关问题 Javascript表单提交不起作用,仅在Internet Explorer中发布 - Javascript Form submit is not working , issue only in internet explorer 在Internet Explorer 6中使用JavaScript的表单提交问题 - Form submit problem using JavaScript in Internet Explorer 6 Javascript表单无法在Internet Explorer上按预期提交 - Javascript form is not able to submit as expected on Internet explorer 带有Internet Explorer的Css浮动标签无法正常工作 - Floating Label with Css not working in edge, internet explorer 输入提交未在Internet Explorer中使用jquery提交表单 - Input submit didn't submit form with jquery in Internet Explorer 下拉选择表单在Internet Explorer中不起作用 - Dropdown select in form not working in Internet Explorer MVC 5 ASP.Net FORM Submit()函数不起作用 - MVC 5 ASP.Net FORM submit() function not working 以编程方式创建的表单无法在Firefox或Internet Explorer中提交 - Programatically Created Form Does Not Submit in Firefox or Internet Explorer 无法提交表单<select multiple required>在 Internet Explorer 中 - Cannot submit form with <select multiple required> in Internet Explorer 填充文本框的窗体按钮在Internet Explorer中不起作用 - Form button that populates textbox is not working in Internet Explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM