【发布时间】:2014-08-12 21:49:43
【问题描述】:
我有一个 div2,只有当 RadioButtonList1 的值为“是”时,我才会通过 javascript 函数 getvalue().Initially 在 div1 中显示它我没有使用 c# 代码显示 div2。
<fieldset id="disc" class="nt_generic">
<div runat="server" id="div1">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
OnClick="getvalue()">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" Selected="True" />
</asp:RadioButtonList>
</div>
<div id="div2" runat="server">
<radC:RadComboBox ID="rcb1" EnableLoadOnDemand="true" runat="server" Skin="WebBlue">
<Items>
<radC:RadComboBoxItem ID="CondoComboBoxItem" runat="server" Text="A Ground" Value="B" Selected="true" />
<radC:RadComboBoxItem ID="HomeComboBoxItem" runat="server" Text="B Ground" Value="A" />
</Items>
</radC:RadComboBox>
</div>
</fieldset>
function getvalue()
{
var value = $('#<%=RadioButtonList1.ClientID %> input[type=radio]:checked').val();
if(value == "Yes")
{
if (document.getElementById("<% = div2.ClientID %>") != null)
document.getElementById("<%= div2.ClientID %>").style.display = "inline-block";
}
else
if (document.getElementById("<% = div2.ClientID %>") != null)
document.getElementById("<%= div2.ClientID %>").style.display = "none";
}
当我按照说明使用上述代码时,div2 首先显示并隐藏我不想要的后记。
如果我像下面这样将visible=false 添加到 div2
<div id="divTankLocated" runat="server" visible="false">
div2没有隐藏和显示,但是javascript函数getvalue()不起作用,并且不能在RadioButtonList1值改变时显示div2。
可以帮助我解决以上 2 点吗?
【问题讨论】:
标签: javascript asp.net radcombobox