【问题标题】:Pre-selected Bootstrap radio buttons won't submit预选的 Bootstrap 单选按钮不会提交
【发布时间】:2018-08-20 00:30:51
【问题描述】:

我有一个 html 文件,其中包含一个通过 php 加载的表单。在此表单中,所有输入字段都显示基于先前输入的值的预选值。当我提交这个加载的表单时,所有的文本框和文本输入都成功提交;但是,除非您再次单击所选值,否则不会提交单选按钮(也具有预选值)。有什么办法可以解决这个问题吗?

这是我正在加载的简化 html:

<form action="report" method="POST" target="_blank">
<div class="btn-group-xs" data-toggle="buttons" id="rop1-1-cons">
    <label class="btn btn-outline-primary active">
         <input type="radio" name="rop1-1-cons" id="rop1-1-cons-5" value="5" autocomplete="off">I
    </label>
</div>
<input type="text" value="Pre-selected User Input"/>
<input type="submit" value="submit"></input>
</form>

标签具有“Active”类,这意味着用户在保存表单 html 之前选择了它。

我认为提及我正在使用引导式单选按钮很有用(我知道,它们有奇怪的行为!)

【问题讨论】:

  • 可以上传html吗?
  • @Unknown 当然。我刚刚做了

标签: php html forms radio-button


【解决方案1】:

checked 属性添加到输入。

<div class="btn-group-xs" data-toggle="buttons" id="rop1-1-cons">
<label class="btn btn-outline-primary active">
     <input type="radio" name="rop1-1-cons" id="rop1-1-cons-5" value="5" autocomplete="off" checked="checked">I
</label>
</div>

【讨论】:

  • 非常感谢。我不知道我是怎么错过的。
猜你喜欢
  • 2013-08-07
  • 2014-03-23
  • 2015-09-19
  • 1970-01-01
  • 2020-11-13
  • 2017-09-01
  • 2014-03-07
  • 2013-04-10
  • 2014-11-08
相关资源
最近更新 更多