关于js的一点问题 dropdownlist_selectedchange() 后台需要这个方法支持,这个不是js。 -------------------------我也是新手 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你这个是服务端事件,不是js事件,js调用是onclick=“dropdownlist_selectedchange()” 上面写错,是onchange=“dropdownlist_selectedchange()” 不好意思 type写错了 应该是type="text/javascript" 照你的方法改过后可以运行,但是我想要的功能却没实现 当选择dropdownlist的内容后 label没有显示对应的值 function dropdownlist_selectedchange() {Label28 = document..getElementById("Label28 "); if (DropDownList1.SelectedValue == "普通医师") { Label28.Text = "5.00元"; } if (DropDownList1.SelectedValue == "专家医师") { Label28.Text = "8.00元"; } if (DropDownList1.SelectedValue == "副主任医师") { Label28.Text = "12.00元"; } if (DropDownList1.SelectedValue == "主任医师") { Label28.Text = "15.00元"; } }加这句 Label28 = document..getElementById("Label28 "); 请问 你分清了 服务器控件跟客户端控件的区别么,直接在js里DropDownList1.SelectedValue 没有这么高级脚本!!! onselectedindexchanged="dropdownlist_selectedchange()"看看这是不是服务器端事件 先理清楚 自己想实现什么功能,然后想想到底什么方式实现更好; 获取值:$("select option:selected").val() ; 直接上代码default.aspx<asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem Text="请选择"></asp:ListItem> <asp:ListItem Text="普通医师"></asp:ListItem> <asp:ListItem Text="专家医师"></asp:ListItem> </asp:DropDownList> <asp:Label ID="Label28" runat="server" Text="Label"></asp:Label>default.aspx.csprotected void Page_Load(object sender, EventArgs e) { DropDownList1.TextChanged += new EventHandler(DropDownList1_TextChanged); } void DropDownList1_TextChanged(object sender, EventArgs e) { if (DropDownList1.Text == "普通医师") { Label28.Text = "5.00元"; } if (DropDownList1.Text == "专家医师") { Label28.Text = "8.00元"; } if (DropDownList1.Text == "副主任医师") { Label28.Text = "12.00元"; } if (DropDownList1.Text == "主任医师") { Label28.Text = "15.00元"; } } onselectedindexchanged 这个是服务端事件,不能调用js IE或Firefox的错误控制台 windows窗体,代码出现错误 GridView 中怎么获取用户控件的值 如何将.resx文件的value值 绑定到gridview控件中? petshop4.0注册问题 哪错了 XML请求获取数据问题(在线) login控件小小问题 .CS文件与后台!指教! 在框架中(frameset分top-bottom)。如何在top.aspx(top)页面中单击button1按钮,在bottom中显示bottom.aspx页面 打印如何通过js设置纵向还是横向 ViewState为什么在Repeater数据绑定之后会失效
当选择dropdownlist的内容后 label没有显示对应的值
{
Label28 = document..getElementById("Label28 ");
if (DropDownList1.SelectedValue == "普通医师")
{
Label28.Text = "5.00元";
}
if (DropDownList1.SelectedValue == "专家医师")
{
Label28.Text = "8.00元";
}
if (DropDownList1.SelectedValue == "副主任医师")
{
Label28.Text = "12.00元";
}
if (DropDownList1.SelectedValue == "主任医师")
{
Label28.Text = "15.00元";
}
}
加这句
看看这是不是服务器端事件
<asp:ListItem Text="请选择"></asp:ListItem>
<asp:ListItem Text="普通医师"></asp:ListItem>
<asp:ListItem Text="专家医师"></asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label28" runat="server" Text="Label"></asp:Label>
default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.TextChanged += new EventHandler(DropDownList1_TextChanged);
} void DropDownList1_TextChanged(object sender, EventArgs e)
{
if (DropDownList1.Text == "普通医师")
{
Label28.Text = "5.00元";
}
if (DropDownList1.Text == "专家医师")
{
Label28.Text = "8.00元";
}
if (DropDownList1.Text == "副主任医师")
{
Label28.Text = "12.00元";
}
if (DropDownList1.Text == "主任医师")
{
Label28.Text = "15.00元";
}
}