duanlushen8940 2013-11-12 16:06
浏览 96
已采纳

组中只有一个(第一个)单选按钮是可选/活动的

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.

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 generated/source:

<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>

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;

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 is the portion of the actual source code generated. Also working in jsfiddle.

  • 写回答

1条回答 默认 最新

  • dtt2012 2013-11-13 14:41
    关注

    For the sake of closing this question:

    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.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号如何开发网页
  • ¥15 h3.6m 人类行为预测论文复现
  • ¥50 wordpress项目注册报失败刷新后其实是成功状态,请求排查原因
  • ¥20 linxu服务器僵尸进程不释放,代码如何修改?
  • ¥15 pycharm激活不成功
  • ¥40 如果update 一个列名为参数的value
  • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
  • ¥15 OCS2安装出现问题,请大家给点意见
  • ¥15 ros小车启动launch文件报错
  • ¥15 vs2015到期想登陆但是登陆不上