日期:2014-05-19  浏览次数:20816 次

textbox自动填值的问题
textbox根据同一页面上dropdownlist所选值来自动填写对应的值,已经完成,而且可以实现自动取值。
aspx.cs代码
                TextBox18.Attributes.Add( "onclick ",   "get_text(this) ");
js代码
        function   get_text(o)
        {
            var       province=document.getElementById( "DropDownList1 ");      
            var       pindex       =       province.selectedIndex;      
            var       pValue       =       province.options[pindex].value;      
            var       pText           =       province.options[pindex].text;  
            switch(pText)
            {
            case   'aa '     :
            document.getElementById( " <%=TextBox18.ClientID%> ").innerText= 'aa1 ';
            break;
            case   'bb '   :  
            document.getElementById( " <%=TextBox18.ClientID%> ").innerText= 'bb1 ';
            break;
            }
        }
问题在于js是在textbox的onclick中实现的,我不想在点击文本框后才出现填值,而是在下拉菜单完成下拉动作的时候就填值,该怎么改?
TextBox18.Attributes.Add( "onclick ",   "get_text(this) ");换成DropDownList1.Attributes.Add( "onclick ",   "get_text(this) ");是不行的

------解决方案--------------------
try

DropDownList1.Attributes.Add( "onpropertychange ", "get_text(this) ")


------解决方案--------------------

DropDownList1.Attributes.Add( "onchange ", "get_text(this) ")