zoukankan      html  css  js  c++  java
  • JQuery select 编程时选中原有的值

    js 此为核心代码

    $(document).ready(function(){
    $("#carTypeId").attr("value",'${carInfo.carTypeId}'); //后台传递的值
    })

    <tr>
    <th width="20%">车辆种类名称: </th>
    <td>
    <%-- <input type="text" id="carTypeId" name="carTypeId" value="${carInfo.carTypeId}" class="inputText" validate="{required:false,number:true,maxIntLen:10}" />
    --%>
    <select name="carTypeId" id ="carTypeId" class="select panel-search-inputText">
    <option value="">--选择--</option>
    <c:forEach items="${listCarType}" var="keyword" varStatus="id">
    <option value="${keyword.id}" <c:if test="${keyword.id} == ${carInfo.carTypeId}">selected</c:if>> ${keyword.typeName} </option>
    </c:forEach>
    </select>
    </td>

    java 代码

    List<CarType> listCarType=carTypeService.getAll();
    return getAutoView().addObject("carInfo",carInfo !=null?carInfo:null)
    .addObject("listCarType", listCarType)

  • 相关阅读:
    macOS 上配置 Lua
    Oracle.ManagedDataAccess.dll
    offer
    Costura.Fody
    日志系统
    实战框架ABP
    什么是算法?
    HTTP状态码->HTTP Status Code
    How to untar a TAR file using Apache Commons
    python实践3:cursor() — 数据库连接操作
  • 原文地址:https://www.cnblogs.com/aibabel/p/10172159.html
Copyright © 2011-2022 走看看