首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >生成无线按钮选项卡

问生成无线按钮选项卡
EN

Stack Overflow用户
提问于 2018-08-16 17:25:34
回答 1查看 89关注 0票数 0

我似乎无法获得我的单选按钮,以便在下面的表格中进行导航。表本身甚至不使用选项卡按钮进行选择,但是页面上的所有其他元素都会选择。单选按钮和表行是通过循环生成的。有没有办法让制表符按钮选择表格,然后浏览单选按钮?如果你需要更多的信息,请告诉我。

网页:

代码语言:javascript
复制
<%-- Loop through all managers and write the radio button options --%>
 <%int managerIndex = 1; %>
   <%foreach (Manager manager in Managers) %>
            <%{ %>
                <%string responseValue = x;%>
                    <td>
                        <table id='RadioButtonList<%=managerIndex %>' border="0" style="height:25px">
                    <%=HtmlHelper.GetRadioButtonGroupHtml("Radio" + managerIndex, item.SurveyQuestionID, manager.ManagerID, manager.ManagerRoleID, rowClass, "radioList1", responseValue)%>
                        </table>
                    </td>
                <%managerIndex++; %>
            <%} %>
            </tr>

代码隐藏:

代码语言:javascript
复制
StringBuilder html = new StringBuilder();

html.Append("<tr>");

// create a hidden blank value that is checked by default
html.Append(String.Format("<td style=\"display:none\"><input id=\"{0}\" type=\"radio\" name=\"ctl_QID{1}_MID{2}\" value=\"{3}\" checked/><label for=\"{4}\"></label></td>", id + 0, questionId, managerId, "", group));

// create the radio buttons for the values of 1-5
for (int i = 1; i <= 5; i++)
{
    // set the button to 'checked' if the response value matches
    if (i.ToString() == responseValue)
        html.Append(String.Format("<td style=\"width:30px\"><input id=\"{0}\" type=\"radio\" name=\"ctl_QID{1}_MID{2}\" value=\"{3}\" checked/><label for=\"{4}\"></label></td>", id + i, questionId, managerId, i, group));
    else
        html.Append(String.Format("<td style=\"width:30px\"><input id=\"{0}\" type=\"radio\" name=\"ctl_QID{1}_MID{2}\" value=\"{3}\" /><label for=\"{4}\"></label></td>", id + i, questionId, managerId, i, group));
}

// create the N/R radio button and set it to 'checked' if necessary
if (responseValue == "NA")
    html.Append(String.Format("<td style=\"width:30px; background-color: #798d8f; text-align: center;\"><input id=\"{0}\" type=\"radio\" name=\"ctl_QID{1}_MID{2}\" value=\"{3}\" checked/><label for=\"{4}\"></label></td>", id + 6, questionId, managerId, "NA", group));
else
    html.Append(String.Format("<td style=\"width:30px; background-color: #798d8f; text-align: center;\"><input id=\"{0}\" type=\"radio\" name=\"ctl_QID{1}_MID{2}\" value=\"{3}\" /><label for=\"{4}\"></label></td>", id + 6, questionId, managerId, "NA", group));

// append the closing <tr> tag
html.Append("</tr>");
return html.ToString();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-16 17:39:24

您可以将表索引属性- tabindex="0"添加到输入无线电元素中。它们将通过(按它们在源中的顺序)使用选项卡键进行聚焦。

0索引是一个特殊的索引。来自MDN:

tabindex="0“意味着元素在顺序键盘导航中应该是可聚焦的,但其顺序是由文档的源顺序定义的。

如果您也喜欢,可以通过更改索引值来使用不同的顺序。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51882415

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档