简体   繁体   English

预选的Bootstrap单选按钮不会提交

[英]Pre-selected Bootstrap radio buttons won't submit

I have an html file containing a form that is being loaded via php. 我有一个html文件,其中包含通过php加载的表单。 In this form, all input fields show pre-selected values based on previously entered values. 以这种形式,所有输入字段都将基于先前输入的值显示预选的值。 When I submit this loaded form, all the textboxes and text inputs are successfully submitted ; 当我提交此加载的表单时,所有文本框和文本输入均已成功提交; however, the radio buttons ( which also have pre-selected values) are not submitted unless, you click on the selected values again. 但是,除非再次单击选定的值,否则不会提交单选按钮(也具有预选的值)。 Is there any way I can fix this? 有什么办法可以解决这个问题?

Here's my simplified html that's being loaded: 这是我正在加载的简化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>

The label has "Active" class which means the user have chosen this before the form html was saved. 标签具有“ Active”类,这表示用户在保存html表单之前已选择了该类。

I think it's useful to mention that I am using bootstrap style radio buttons (I know, they have strange behaviors!) 我认为值得一提的是,我正在使用引导程序样式的单选按钮(我知道,它们的行为很奇怪!)

Add the checked attribute to the input. 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM