• 二级联动(javascript Array)


    <script language="javascript" type="text/javascript">
    <!--
    var arrSubRelatingType = new Array(); //关联交易子类
        <%                          
            VOList relating_type 
    = (VOList)request.getAttribute("typenameListrelating");                                 
            
    for(int i = 0; i < relating_type.count(); i++)
            
    {    
        
    %>
                arrSubRelatingType[
    <%=i%>= new Array();
                arrSubRelatingType[
    <%=i%>][0]='<%=relating_type.get(i).getString("type_id")%>';        
                arrSubRelatingType[
    <%=i%>][1]='<%=relating_type.get(i).getString("type_name")%>';    
                arrSubRelatingType[
    <%=i%>][2]='<%=relating_type.get(i).getString("group_id")%>';                        
        
    <%     
            }
        
        
    %>

        
    // 增加一个名为 trim 的函数作为 String 构造函数的原型对象的一个方法
            String.prototype.trim = function()
            
    {
                
    // 用正则表达式将前后空格
                // 用空字符串替代。
                return this.replace(/(^\s*)|(\s*$)/g, "");
            }

             
    //二级联动
            function linkage(selBigID,selSmallID,tip,arrSmallClass)
            
    {
                
    var objL = document.getElementById(selBigID);
                
    var obj = document.getElementById(selSmallID);
                obj.length 
    = 0;
                
    if(tip.trim()=="") tip="-请选择-";  
                
                
    if(objL.selectedIndex == 0)
                
    {                
                    obj.options[
    0= new Option(tip, ""); 
                    
    return;
                }
                
                
                
    var len = 0;
                
    var bigClassId = objL.options[objL.selectedIndex].value;  
                
    var tip2 = "-无子类-";
                
    for(var i=0; i<arrSmallClass.length; i++)
                
    {
                    
    //alert(bigClassId +' --- '+ arrSmallClass[i][2]);
                    if(arrSmallClass[i][2== bigClassId)
                    
    {
                        tip2 
    = tip;
                        obj.options[
    ++len] = new Option(arrSmallClass[i][1], arrSmallClass[i][0]);
                    }

                }
             
                obj.options[
    0= new Option(tip2, "");   
               }

       
    //-->
      
    </script>

    ============================================
     
    <td height="35" align="right">关联交易大类别:</td>
          
    <td height="35">
              
    <select id="drpBig_relating_type" name="drpBig_relating_type" Onchange="javascript:linkage(this.id,'drpSmall_relating_type','',arrSubRelatingType);">
                 
    <option value="">-请选择-</option>        
                 
    <exp:options name="drpBig_relating_type" list="groupnameListrelating" idfield="group_id" namefield="group_name" default="<%=this.value("val_big_relating","")%>" />     
              
    </select>
          
    </td>
          
    <td height="35" align="right">关联交易子类别:</td>
          
    <td height="35">
          
    <select id="drpSmall_relating_type" name="drpSmall_relating_type">
               
    <option value="">-请选择-</option>
             
    <exp:options name="drpSmall_relating_type" list="typenameListrelatingSub" idfield="type_id" namefield="type_name" default="<%=this.value("val_small_relating","")%>"/>
          
    </select>
          
    </td>
  • 相关阅读:
    面向对象与面向过程的区别
    IE浏览器上传文件时本地路径变成”C:\fakepath\”的问题
    ldap bdb_db_open 错误解决办法
    转载:技术普及帖:你刚才在淘宝上买了一件东西
    js错误捕捉
    Linux服务器管理系统wdcp Lanmp
    [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 0.引言
    发一个自己写的账号管理软件
    [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 4.Basic jQuery Theory jQuery理论基础
    资源下载(2011609更新)
  • 原文地址:https://www.cnblogs.com/ding0910/p/624074.html
Copyright © 2020-2023  润新知