我有两个单选按钮列表,并希望根据第一个单选按钮列表中的选择更改第二个单选按钮列表项中列表项的文本。获取所选值正在工作,但尚未弄清楚如何为单选按钮 2 中的项目设置单独的文本标签。代码如下。非常感谢。
<script type="text/javascript">
$(document).ready(function () {
$("#<%=rb1.ClientID%>").change(function () {
var rbvalue = $("input[@name=<%=rb1.ClientID%>]:radio:checked").val();
if (rbvalue == "0") {
<!-- need to: -->
<!-- set rb2 list item 1 text to 'sample 1' -->
<!-- set rb2 list item 2 text to 'sample 2' -->
}
else if (rbvalue == "1") {
<!-- need to: -->
<!-- set rb2 list item 1 text to 'sample 3' -->
<!-- set rb2 list item 2 text to 'sample 4' -->
}
});
});
</script>
以下是后面代码中的示例单选按钮:
<asp:radiobuttonlist id="rb1" runat="server">
<asp:listitem value="0">Option1</asp:listitem>
<asp:listitem value="1">Option2</asp:listitem>
</asp:radiobuttonlist>
<asp:radiobuttonlist id="rb2" runat="server">
<asp:listitem value="0" Text="change me 1"></asp:listitem>
<asp:listitem value="1" Text="change me 2"></asp:listitem>
</asp:radiobuttonlist>