zoukankan      html  css  js  c++  java
  • 菜单联动 加翻页

    /**
    * 调用该js,品牌id必须为brand 车系id为series 车型id为carModel
    * 品牌option listKey为品牌内部id
    * 必须放两个隐藏域
    * <input type="hidden" id="seriesId" name="seriesId" value="${?.seriesId}"/>
    <input type="hidden" id="typeId" name="typeId" value="${?.carTypeId}"/>
    * @returns
    */
    $(document).ready(function(){
    $("#brand").onchange=brandchang();
    var seriesid=$("#seriesId").attr("value");
    //$("#series").attr("headerKey",seriesid);
    var t = document.getElementsByName("option1");
    //alert(t.length+"wwwww")
    for(i=0;i<t.length;i++){//给select赋值
    if(seriesid==t[i].value){
    t[i].selected=true
    }
    }

    $("#series").onchange=serieschang();
    var typeid=$("#typeId").attr("value");
    var t1=document.getElementsByName("option2");
    for(i=0;i<t1.length;i++){//给select赋值
    if(seriesid==t1[i].value){
    t1[i].selected=true
    }
    }
    })

    //js获取项目根路径,如: http://localhost:8083/uimcardprj
    function getRootPath(){
    //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
    var curWwwPath=window.document.location.href;
    //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
    var pathName=window.document.location.pathname;
    var pos=curWwwPath.indexOf(pathName);
    //获取主机地址,如: http://localhost:8083
    var localhostPaht=curWwwPath.substring(0,pos);
    //获取带"/"的项目名,如:/uimcardprj
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    return(localhostPaht+projectName);
    }


    function brandchang(){
    var brandInnerId=$("#brand").val();
    var path = getRootPath();
    $.ajax({url:path+"/carBrandUtil/findSeries.do?brandInnerId="+brandInnerId,
    dataType:"json",
    async: false,
    success:function(data){
    var obj=data.series;
    var n=obj.length;
    var htl="<option selected='selected' value='' name='option1'>请选择</option>";
    $("#carModel").html(htl);
    for(var i=0;i<n;i++){
    htl=htl+"<option value=""+obj[i].id+"" name='option1'>"+obj[i].serisName+"</option>"
    }

    $("#series").html(htl);
    //$("#series").attr("list",data.series);
    }
    });
    }
    function serieschang(){
    var seriesInnerId=$("#series").val();
    // alert(seriesInnerId+"fffff")
    var path = getRootPath();
    $.ajax({url:path+"/carBrandUtil/findCarType.do?seriesInnerId="+seriesInnerId,
    dataType:"json",
    async: false,
    success:function(data){
    var obj=data.type;
    var n=obj.length;
    var htl="<option selected='selected' value='' name='option2'>请选择</option>";
    for(var i=0;i<n;i++){
    htl=htl+"<option value=""+obj[i].id+"" name='option2'>"+obj[i].simpleName+"</option>"
    }

    $("#carModel").html(htl);
    }
    });
    }

    <form action="getCarLists.do" name="userListform" method="post" namespace="/lovecar" >
    <input type="hidden" id="errorMsg" name="errorMsg" value="${errorMsg}"/>
    <input type="hidden" id="seriesId" name="seriesId" value="${condtionBizBean.seriesId}"/>
    <input type="hidden" id="typeId" name="typeId" value="${condtionBizBean.carTypeId}"/>
    <div class="formContainer">
    <table class="layout">
    <tbody>
    <tr>
    <td><div>用户姓名:</div></td><td><input type="text" name="condtionBizBean.realName" style="120px" value="${condtionBizBean.realName}"/></td>
    <td><div>电话:</div></td><td><input type="text" name="condtionBizBean.loginNumber" style="120px" onkeyup="this.value=this.value.replace(/D/g,'')" value="${condtionBizBean.loginNumber}" /></td>
    <td><div> 驾照号码:</div></td><td><input type="text" name="condtionBizBean.license" value="${condtionBizBean.license}"></input></td>
    <td><div>车牌号:</div></td><td><input type="text" name="condtionBizBean.plateNumber" style="120px" value="${condtionBizBean.plateNumber}"/></td>
    <td><div>车驾号码:</div></td><td><input type="text" name="condtionBizBean.frameNumber" style="120px" value="${condtionBizBean.frameNumber}" /></td>
    </tr>
    <tr>
    <td><div> 所在城市:</div></td><td><input type="text" name="condtionBizBean.city" value="${condtionBizBean.city}"></input></td>
    <td><div>品牌:</div></td>
    <td><s:select list="carBrandList" id="brand" name="condtionBizBean.brandId" onchange="brandchang()" headerKey="" headerValue="请选择" listKey="id" listValue="brandName" cssStyle=" 120px;" /></td>
    <td><div>车系:</div></td>
    <td>
    <s:select list="carSeriesList" id="series" name="condtionBizBean.seriesId" onchange="serieschang()" headerKey="" headerValue="请选择" listKey="id" listValue="serisName" cssStyle=" 120px;"/>
    <!-- <option selected="selected" value="">请选择</option>

    </select> -->
    </td>
    <td><div>车型:</div></td>
    <td><s:select list="carTypeList" id="carModel" name="condtionBizBean.carTypeId" headerKey="" headerValue="请选择" listKey="id" listValue="simpleName" cssStyle=" 120px;"/>
    <!-- <option selected="selected" value="">请选择</option>
    </slect> -->
    </td>
    </tr>

    </tbody></table>
    </div>
    <div class="anniu">
    <input type="submit" value="查询"/>
    <%-- <s:submit action="LoveCarAction" method="getCarLists" cssStyle="60px" value="查询" onclick="document.forms['userListform'].action='getCarLists.do';"/> --%>
    </div>

  • 相关阅读:
    SpringMVC+Shiro权限管理(转载)
    面试常见问题(转载)
    JavaScript 五种(非构造方式)继承
    JavaScript 五种(构造方式)继承
    Quartz.Net 基于XML配置启动
    jexus防止产生 *.core文件
    Last-Modified、ETag、Expires和Cache-Control
    正则表达式记录
    C# 操作mongodb子文档
    ASP.NET Core "完整发布,自带运行时" 到jexus
  • 原文地址:https://www.cnblogs.com/xuehen/p/4698769.html
Copyright © 2011-2022 走看看