zoukankan      html  css  js  c++  java
  • dropdownlist加Js 实现联动

    1.在前天添加两个控件DropDownList和TextBox,在后台给DropDownList赋值和属性的值

    View Code
                DropDownList1.Items.Add(new ListItem(" ", " "));
    ListItem item
    = new ListItem("1+1", "1");//绑定value
    item.Attributes.Add("key", "2");//绑定属性的value
    DropDownList1.Items.Add(item);
    ListItem item2
    = new ListItem("2+2", "2");
    item2.Attributes.Add(
    "key", "4");
    DropDownList1.Items.Add(item2);

    2.在前台

    View Code
    //DropDownList1后面添加onchange="ChangeDDL(this)"

    <script type="text/javascript">
    function ChangeDDL(obj) {
    var DropDownList1
    = document.getElementById("<%=DropDownList1.ClientID %>");
    var TextBox1
    = document.getElementById("<%=TextBox1.ClientID %>");
    if (obj.value == " ") {
    TextBox3.value
    = "";
    }
    else {
    var text
    = obj.options[obj.selectedIndex].getAttribute("key");
    TextBox1.value
    = text ;
    }
    }
    </script>
  • 相关阅读:
    细节决定成败,为什么他能挣15亿
    GLSL Notes
    Connecting Physics Bodies
    Pylint
    Physicals
    Advanced Scene Processing
    Working with Other Node Types II
    OperateParticleWithCodes
    SpriteParticle II
    Working with Other Node Types
  • 原文地址:https://www.cnblogs.com/bulege/p/2134476.html
Copyright © 2011-2022 走看看