【问题标题】:Radio Button checked not changing选中的单选按钮未更改
【发布时间】:2021-08-05 17:40:48
【问题描述】:

我正在使用的表单有一个奇怪的问题。我有以下内容:

<?php 
    $show = ' checked ';
    $hide = ' ';

    /* Some logic to swap the checked here */
?>
<label class="radio-inline" for="show">Show</label>
<input type="radio" id="show" name="show" value="1" {{ $show }} />
<label class="radio-inline" for="hide">Hide</label>
<input type="radio"  id="hide" name="show" value="0" {{ $hide }} />

此代码以显示在 Ajax 模式中的表单加载。 $show 的初始状态有效,它设置为checked。但是,当我单击隐藏时,单选切换但属性不会更改为选中,$show 保持选中状态。

任何帮助将不胜感激。

【问题讨论】:

  • 你在哪里观察这个值?在浏览器检查器中?

标签: php html ajax laravel


【解决方案1】:

单选选项的名称必须相同。

<input type="radio" id="show" name="visibility" value="1" {{ $show }} />
<input type="radio"  id="hide" name="visibility" value="0" {{ $hide }} />

【讨论】:

  • 我的错误,在我的原始代码中它们是相同的,忘记在这里编辑它。现在编辑上面的代码
猜你喜欢
  • 2013-07-24
  • 1970-01-01
  • 2017-05-11
  • 2021-06-14
  • 1970-01-01
  • 2021-08-16
  • 1970-01-01
  • 2012-06-09
  • 1970-01-01
相关资源
最近更新 更多