dropdownlist_selectedchange()   后台需要这个方法支持,这个不是js。   -------------------------我也是新手

解决方案 »

  1.   

    你这个是服务端事件,不是js事件,js调用是onclick=“dropdownlist_selectedchange()”
      

  2.   

    上面写错,是onchange=“dropdownlist_selectedchange()”
      

  3.   

    不好意思 type写错了 应该是type="text/javascript"
      

  4.   

    照你的方法改过后可以运行,但是我想要的功能却没实现 
    当选择dropdownlist的内容后 label没有显示对应的值
      

  5.   

     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元";
                }
        }
    加这句
      

  6.   

    Label28 = document..getElementById("Label28 ");
      

  7.   

    请问 你分清了 服务器控件跟客户端控件的区别么,直接在js里DropDownList1.SelectedValue   没有这么高级脚本!!!
      

  8.   

     onselectedindexchanged="dropdownlist_selectedchange()"
    看看这是不是服务器端事件
      

  9.   

    先理清楚 自己想实现什么功能,然后想想到底什么方式实现更好;   获取值:$("select option:selected").val() ;
      

  10.   

    直接上代码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.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元";
                }
            }
      

  11.   

    onselectedindexchanged 这个是服务端事件,不能调用js