zoukankan      html  css  js  c++  java
  • 可输入的DropDownList控件

     1<%@ Page language="c#" Codebehind="ddlWriteControl.aspx.cs" AutoEventWireup="false" Inherits="WebDemo.ddlWriteControl" %>
     2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
     3<HTML>
     4    <HEAD>
     5        <title>ddlWriteControl</title>
     6        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
     7        <meta name="CODE_LANGUAGE" Content="C#">
     8        <meta name="vs_defaultClientScript" content="JavaScript">
     9        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    10        <style> #div1 { Z-INDEX: 1; LEFT: 250px; WIDTH: 216px; CLIP: rect(3px 280px 21px 110px); POSITION: absolute; TOP: 89px; HEIGHT: 72px } #div2 { LEFT: 250px; WIDTH: 95px; POSITION: absolute; TOP: 89px; HEIGHT: 18px; 2: } </style>
    11    </HEAD>
    12    <body MS_POSITIONING="GridLayout">
    13        <script language="javascript">
    14        function AddOption()
    15        {    
    16            var val = document.getElementById("txtValue").value;
    17            var option = document.getElementById("ddl");
    18            
    19            if(val == "")
    20            {
    21                alert("请输入项值");
    22                return;
    23            }

    24            if(option.length > 0)
    25            {
    26                for(var i=0;i<option.length;i++)
    27                {
    28                    if(option.options[i].value == val)
    29                    {
    30                        alert("该值已存在!");
    31                        return;
    32                    }

    33                }

    34            }

    35            
    36            var option_val = new Option(val,val);
    37                        
    38            option.add(option_val);
    39            option.selectedIndex = option.options.length-1;
    40            
    41        }

    42        
    </script>
    43        <form id="Form1" method="post" runat="server">
    44            <div id="div1" style="Z-INDEX: 101; WIDTH: 128px; HEIGHT: 72px">                
    45                <asp:DropDownList id="ddl" onchange="document.getElementById('txtValue').value = this.value" runat="server"
    46                    Width="127">
    47                    <asp:ListItem Value="aaa1">aaa1</asp:ListItem>
    48                    <asp:ListItem Value="bbb2">bbb2</asp:ListItem>
    49                    <asp:ListItem Value="ccc3">ccc3</asp:ListItem>
    50                </asp:DropDownList>
    51            </div>
    52            <FONT face="宋体"></FONT>
    53            <div id="div2">                
    54                <asp:TextBox id="txtValue" style="PADDING-LEFT:2px;PADDING-TOP:2px" runat="server" Width="127"></asp:TextBox>
    55                <input type="button" value="OK" id="btn" onclick="AddOption();">
    56            </div>
    57            
    58        </form>
    59    </body>
    60</HTML>
    61
    如果有问题请与我联系。
  • 相关阅读:
    腾讯开源 APIJSON 连创五个第一
    最火的分布式 HTAP 数据库 TiDB
    完爆Facebook/GraphQL,APIJSON全方位对比解析(三)-表关联查询
    后端自动化版本管理,再也不用改URL了!
    后端开挂:3行代码写出8个接口!
    3步创建服务端新表及配置
    Activity猫的一生-故事解说Activity生命周期
    APIJSON-以坚持和偏执,回敬傲慢和偏见
    APIJSON,让接口和文档见鬼去吧!
    Android 100多个Styles快速开发布局XML,一行搞定View属性,一键统一配置UI...
  • 原文地址:https://www.cnblogs.com/Lewis/p/455858.html
Copyright © 2011-2022 走看看