gpt4 book ai didi

javascript - 如何从单选按钮列表中更改已选择的单选按钮的颜色

转载 作者:行者123 更新时间:2023-11-30 00:11:27 25 4
gpt4 key购买 nike

我有一个单选按钮列表。最初它的选定值被捕获并存储到数据库中。当我重新访问该页面时,我之前选择的单选按钮将显示为已选中。现在我想用不同的颜色更改/突出显示所选按钮。

<asp:RadioButtonList RepeatColumns="5" class="style_radio"   ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Table" Width="100%">
<asp:ListItem Text="" Value="1000"></asp:ListItem>
<asp:ListItem Text="" Value="2000"></asp:ListItem>
<asp:ListItem Text="" Value="3000"></asp:ListItem>
<asp:ListItem Text="" Value="4000"></asp:ListItem>
<asp:ListItem Text="" Value="5000"></asp:ListItem>
</asp:RadioButtonList>

在页面加载时,我写如下,

SqlCommand cmd = new SqlCommand("Select selected_salary from staff_details where staff_id="ACD11" ", con6);
SqlDataReader dr2 = cmd.ExecuteReader();
if (dr2.HasRows == true)
{
while (dr2.Read())
{
string salary = dr2[0].ToString();
RadioButtonList rb = (RadioButtonList)Page.FindControl("RadioButtonList1");
rb.SelectedValue = salary;

}
}

最佳答案

如果我明白你想要什么,目的是改变选中单选按钮的颜色/外观,对吗?在这种情况下,您可以只定义选中的单选按钮的 css,例如:

[type="radio"]:checked 
{
width: 16px;
height: 16px;
background-image: ...
}

希望这对您有所帮助。

关于javascript - 如何从单选按钮列表中更改已选择的单选按钮的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36328140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com