欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在ASP.NET中自动添加文本框或者dropdownlist 博客分类: ASP.NET asp.net 

程序员文章站 2024-03-16 08:00:33
...
前台js代码:

   <script type="text/javascript">
     function AddInputArea() {
         var div = document.createElement("<div>");
         div.innerHTML = "<table id='TbForm'><tr><td>查询对象</td><td><select name='select'><option value=''>请选择</option><option value='Ip'>Ip</option><option value='Type'>设备类型</option><option value='Fixed_Assets'>固定资产</option><option value='Mac_Address'>Mac地址</option><option value='Internet'>Internet</option><option value='Chinese_OS'>中文OS</option><option value='Chinese_Win'>中文Win</option><option value='Chinese_Office'>中文Office</option><option value='Kingsoft'>金山词霸</option><option value='Acdsee'>Acdsee</option><option value='Win_Rar'>Win_Rar</option><option value='Jinpan_Win'>日文Win</option><option value='Jinpan_Office'>日文Office</option><option value='Jinpan_OS'>日文OS</option><option value='Jacdsee'>日文adcsee</option><option value='Jwinrar'>日文winrar</option><option value='Autocad'>Autocad</option><option value='SQL_Database'>SQL数据库</option><option value='Adobe_Acrobat'>采购日期</option><option value='VS'>VS</option><option value='Warranty_Time'>保修期限</option><option value='Device_Use'>设备用途</option><option value='Device_Name'>设备名称</option><option value='Storage_Location'>存储位置</option><option value='Acquired_Date'>采购日期</option><option value='a.Departments_ID'>使用部门</option><option value='User'>使用者</option><option value='Machine_Id'>机器名称</option><option value='Sts_Info'>使用情况</option><option value='Device_Info'>设备信息</option><option value='Assert_Sn'>资产编号</option></select></td><td>条件</td><td><select name='inputName'><option value=''>请选择</option><option value='='>等于</option><option value='>'>大于</option><option value='<'>小于</option><option value='!='>不等于</option><option value='>='>大于等于</option><option value='<='>小于等于</option><option value='LIKE%'>模糊匹配</option></select></td><td>查询内容</td><td><input name='inputSum' type='text'/></td><td>并列条件</td><td><select name='inputCondition'><option value=' '>请选择</option><option value='OR'>或者</option><option value='AND'>并且</option><select></td></tr></table>";
         document.getElementById("Content").appendChild(div);
        
     }
     function GetAddInput() {

         var strSql = "";
         var names = document.getElementsByName("inputName");
         var select = document.getElementsByName("select");
         var inputCondition = document.getElementsByName("inputCondition");
         if (names.length == 0) {
             alert("没有可用的信息!");
             return false;
         }
         var genders = document.getElementsByName("inputSum");

         for (var i = 0; i < names.length; i++) {

            if (select[i].value=="")
            {
                alert("查询对象不能为空!");
                break;
            }
            if (names[i].value == "") {
                alert("条件不能为空!");
                break;
            }
            if (genders[i].value == "") {
                alert("内容不能为空!");
                break;
            }
           
            strSql += "(" + select[i].value + " " + names[i].value + " " + "'"+genders[i].value+"'" + ")" + " " + inputCondition[i].value;
          
         }
         document.getElementById("hf_Sql").value = strSql;
     }      
  </script>


html代码:
    <html>
       <head>
       </head>
       <body> 
          <div id="Content">
          </div>
          <asp:HiddenField  ID="hf_Sql" runat="server" />
          <asp:Label ID="lbSql" runat="server"></asp:Label>
       </body>
    </html>
后台代码
      string strSql = hf_Sql.Value; 
       hbSql.text=   strSql ;    
  
相关标签: asp.net