组中只有一个(第一个)单选按钮可以选择/激活 [英] Only one (the first) radio button in a group is selectable / active

查看:101
本文介绍了组中只有一个(第一个)单选按钮可以选择/激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用数据库中的数据生成了几组单选按钮.目前,我只能单击/成功选择这些单选按钮组中的第一个,其他按钮则无响应.

I have a few groups of radio buttons being generated using data from a database. Currently I am only able to click on / successfully select the first of these groups of radio buttons, the others are unresponsive.

当我分别在 jsfiddle 中对其进行测试时,该代码可以正常工作,所以我认为这不是,但是无论如何在这里

The code when I test it separately in jsfiddle works fine, so I don't think it is that, however here it is anyway

HTML生成/来源:

<div class="radio">
  <div>
      <input type="radio" id="a" value="A" name="Q1" /> 
      <span class="inline">A</span>
  </div>
  <div>
      <input type="radio" id="b" value="B" name="Q1" /> 
      <span class="inline">B</span>
  </div>
  <div>
      <input type="radio" id="c" value="C" name="Q1" /> 
      <span class="inline">C</span>
  </div>
  <div>
      <input type="radio" id="d" value="D" name="Q1" /> 
      <span class="inline">D</span>
  </div>
  <div>
      <input type="radio" id="e" value="E" name="Q1" /> 
      <span class="inline">E</span>
  </div>
</div>

这里值得使用的是我用来构建以上代码的PHP:

For what it is worth here is the PHP I am using to build the above:

$questions .='
<div class="radio">
';

foreach($values_data as $ke=>$va)
    {
    $questions.='
    <div><input  '.$tooltip.' type="radio" id="question_'.$i.'_'.$va['value'].'" value="'.$va['value'].'" name="question_'.$i.'" />
    <span class="inline">'.$va['value'].'</span></div>
    ';
    }

$questions .='
</div>
<div class="clear"></div>
';

echo $questions;

以上内容位于定义$ i并调用数据库以构建数组等的循环中.

Where the above sits inside a loop that is defining $i and calling on databases to build arrays etc.

我的控制台中没有错误.有什么想法吗?谢谢

There are no errors in my console. Any ideas what this could be? Thanks

HERE 是生成的实际源代码的一部分.也可以在jsfiddle中工作.

HERE is the portion of the actual source code generated. Also working in jsfiddle.

推荐答案

为了结束这个问题:

这是一个奇怪的问题,css属性似乎阻止了元素之间的正确交互:从单选元素中删除float:right或display:inline使它们再次单击即可.

This was a strange issue where by it seemed like the css properties were preventing proper element interaction: removing either float: right, or display: inline from the radio elements made them click able again.

我不确定为什么会这样,但是我通过强制.radio类具有display:block;来解决了这个问题.代替.

I am not sure why this is, but I solved the issue by forcing the .radio class to have display: block; instead.

这篇关于组中只有一个(第一个)单选按钮可以选择/激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆