duanmao2650 2016-08-15 08:23
浏览 118

多个动态创建的行上的单选按钮状态

I have a form which has multiple rows generated by a query. Each row has a radio button group with three radio buttons.

What I am trying to do is to have each rows radio group work independantly of each other.

Example:

Row 1 (radio button 1) (radio button 2) (radio button 3)

Row 2 (radio button 1) (radio button 2) (radio button 3)

Row 3 (radio button 1) (radio button 2) (radio button 3)

At the moment if I click on any of the buttons in any of the rows its only row 1 that changes the status of the button.

My code:

do { 
    <input type="radio" name="action[<?php echo $row_TQ01['SeqID']; ?>]0" value="2" id="Action1_0" class="radio_item">
    <label class="label_item" for="Action1_0"> <img src="images/fix_2.png"> </label>
    <input name="action[<?php echo $row_TQ01['SeqID']; ?>]0" type="radio" class="radio_item" id="Action1_1" value="1" checked="CHECKED">
    <label class="label_item" for="Action1_1"> <img src="images/fail_2.png"> </label>
    <input type="radio" name="action[<?php echo $row_TQ01['SeqID']; ?>]0" value="0" id="Action1_2" class="radio_item">
    <label class="label_item" for="Action1_2"> <img src="images/pass_2.png"> </label>
} while ($row_TQ01 = mysql_fetch_assoc($TQ01)); 

I do have some CSS to dim or highlight the selected radio button but I have tested the code without the styling and is the same. my style is:

<style>
.radio_item{
    display: none !important;
}

.label_item {
opacity: 0.4;
}

.radio_item:checked + label {
opacity: 1;
}

label {
cursor: pointer;   
}

Can anyone see why only row 1 changes button status.

Many thanks in advance for your time.

  • 写回答

2条回答 默认 最新

  • doudang4568 2016-08-15 08:30
    关注

    the thing is in radio buttons the name should be same then only it works one at a time, if you keep all rows radio buttons name attribute same then it will work everywhere

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型