-----------------------//脚本
function mustInput(obj)
{
  //var lbid=document.getElementById("Label1");
  if(this.value=="1"||this.value=="3")
  {
   document.getElementById("Label1").style.display=""; 
  }
  else
    document.getElementById("Label1").style.display="none";
}
----------------------------------//注册
this._dflx.Attributes.Add("onchange","mustInput(this)");
----------------------------------控件
<asp:dropdownlist id="_dflx" Runat="server" Width="141px">
<asp:ListItem Value="1">直付</asp:ListItem>
<asp:ListItem Value="2">托收</asp:ListItem>
<asp:ListItem Value="3">室分</asp:ListItem>
</asp:dropdownlist>
--------------------------------
<asp:label id="Label1" runat="server" ForeColor="Red">缴费时间间隔必填</asp:label>
----------------------------------
为什么选择没反映,也没说脚本错误??!菜鸟!谢谢!!!!!!

解决方案 »

  1.   

    _dflx.Attributes["onchange"] = "mustInput(this);";
      

  2.   


    -----------------------//脚本
    function mustInput(obj,obj1)
    {
      //var lbid=document.getElementById("Label1");
      if(obj.value=="1" ||obj.value=="3")
      {
      document.getElementById(obj1).style.display="";
      }
      else
        document.getElementById(obj1).style.display="none";
    }
    ----------------------------------//注册
    this._dflx.Attributes.Add("onchange","mustInput(this,'"+Label1.ClientID+"')");
    ----------------------------------控件
    <asp:dropdownlist id="_dflx" Runat="server" Width="141px">
    <asp:ListItem Value="1">直付 </asp:ListItem>
    <asp:ListItem Value="2">托收 </asp:ListItem>
    <asp:ListItem Value="3">室分 </asp:ListItem>
    </asp:dropdownlist>
    --------------------------------
    <asp:label id="Label1" runat="server" ForeColor="Red">缴费时间间隔必填 </asp:label>
    ---------------------------------- 
      

  3.   

    注册的那句放在:IsPostBack外。