当复选框选中时value值为1,未选中value值为0。

<div class="input-group-text">
<input type="checkbox" id="isAuto"  onclick="document.getElementById('autoValue').value=this.checked?1:0" checked">
<input type="hidden" name="isAuto" id="autoValue" value="1">
</div>

 重点:

1、javascipr代码直接用三元运算符写在onclick事件中,这个用JQ应该也可以。

2、必须有隐藏域,事件似乎无法改变自身控件的属性。

相关文章:

  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2021-05-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-02
  • 2022-01-18
  • 2021-08-01
  • 2022-03-02
  • 2022-12-23
  • 2022-02-14
相关资源
相似解决方案