0

在表格中使用以下代码,该表格在单击该行时选择收音机。它可以工作到 IE9,但这段代码在 IE10 及更高版本或 chrome 中不起作用。谁能建议他们是否遇到过类似的问题?任何涉及少量修改的建议都会有所帮助。

<LABEL FOR="radio<%=k%>" align="top">
<TR BGCOLOR="#<%=rowColor%>">
    <TD WIDTH="25" VALIGN="top"><INPUT TYPE="RADIO" NAME="xyz"
        <%=checked%> ID="radio<%=k%>" VALUE="<%=value%>"></TD>
    <TD WIDTH="120" VALIGN="top"><%=value%></TD>
    <TD WIDTH="145" VALIGN="top"><%=value%>
    <%=value%></TD>
    <TD WIDTH="135" VALIGN="top"><%=value%>
    <%=value%></TD>
    <TD WIDTH="50" VALIGN="top"><%=value%></TD>
    <TD WIDTH="*" VALIGN="top"><%=value%>
    </TD>
</TR>
</LABEL>
4

1 回答 1

0

您不能tr在单独的label. 尝试一些脚本来实现这一点。

function toggle_row(e, row_id) {
  e = e || window.event; //get event
  var el = e.srcElement || e.target; //get the right html element, on which user clicked
  var input = document.getElementById(row_id);//get the checkbox for the row clicked
  if (el != input) //checkbox was not clicked
    input.checked = !input.checked; //flip the checkbox selection
}
tr {
  cursor: pointer;
}
<table>
  <tr onclick="toggle_row(event,'row_1')">
    <td>
      <input type="checkbox" id="row_1" />
    </td>
    <td>Foo</td>
    <td>Bar</td>
  </tr>
  <tr onclick="toggle_row(event,'row_2')">
    <td>
      <input type="checkbox" id="row_2" />
    </td>
    <td>Foo</td>
    <td>Bar</td>
  </tr>
  <tr onclick="toggle_row(event,'row_3')">
    <td>
      <input type="checkbox" id="row_3" />
    </td>
    <td>Foo</td>
    <td>Bar</td>
  </tr>
</table>

于 2017-01-02T09:21:22.507 回答