zoukankan      html  css  js  c++  java
  • [原创]用JS给DropDownList添加新项!



    <script language="javascript">
            
    function addItem()
            {
             
    if (document.all("v").value==""return;
             
    var tOption = document.createElement("Option");
             tOption.text
    =document.all("v").value;
             tOption.value
    =document.all("DDL1").options.length+1;
             document.all(
    "DDL1").add(oOption);



            }
            
            
    </script>

        <DIV style="BORDER-RIGHT: 1px dotted; BORDER-TOP: 1px dotted; Z-INDEX: 103; LEFT: 304px; BORDER-LEFT: 1px dotted; WIDTH: 304px; BORDER-BOTTOM: 1px dotted; POSITION: absolute; TOP: 288px; HEIGHT: 160px; BACKGROUND-COLOR: ghostwhite"
                    ms_positioning
    ="GridLayout"><INPUT onclick="addItem();" style="Z-INDEX: 101; LEFT: 136px; WIDTH: 99px; POSITION: absolute; TOP: 56px; HEIGHT: 22px"
                        type
    ="button" value="添加新项目" id="addnew">
                    
    <asp:DropDownList id="DDL1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 96px" runat="server"
                        Width
    ="96px">
                        
    <asp:ListItem Value="0">北京</asp:ListItem>
                        
    <asp:ListItem Value="1">天津</asp:ListItem>
                        
    <asp:ListItem Value="2">上海</asp:ListItem>
                    
    </asp:DropDownList><INPUT id="v" style="Z-INDEX: 103; LEFT: 32px; WIDTH: 96px; POSITION: absolute; TOP: 56px; HEIGHT: 22px"
                        type
    ="text" size="10"></DIV>
  • 相关阅读:
    解决移动端页面在苹果端滑不到底部的问题
    js点击事件在苹果端失效的问题
    小程序开发基本步骤
    css多行文本省略号(...)
    js判断pc端和移动端的方法
    主流浏览器css兼容问题的总结
    让ie6对png透明图片支持起来
    ajax的探究与使用
    css3实现逐渐变大的圆填充div背景的效果
    js中setTimeout()时间参数设置为0的探讨
  • 原文地址:https://www.cnblogs.com/goody9807/p/186602.html
Copyright © 2011-2022 走看看