laytpl模版引擎不能写select标签....

提问 已结
6 743
1253398319
1253398319 2017-1-6
悬赏:20飞吻
回帖
  • 是这样的吧:laytpl渲染之后才出现的html,有html之后你再去渲染select就出来了
    0 回复
  • 页面效果没有下拉列表...
    0 回复
  • vip_admin
    2017-1-6
    好像是要在form表单内,js要使用form模块才行
    0 回复
  • 如果去掉模版,则select可以出来.
    0 回复
  • <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <title>个人信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="jsp/common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="jsp/common/bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="jsp/common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="jsp/userMg/css/personal.css" media="all">
    </head>
    <body>
    <section class="layui-larry-box">
    <div class="larry-personal">
    <header class="larry-personal-tit">
    <span>个人信息</span>
    </header><!-- /header -->
    <div class="larry-personal-body clearfix">
    <form id="view" class="layui-form col-lg-5" lay-filter="aa" action="" method="post">
    <div class="layui-form-item">
    <label class="layui-form-label">开户银行</label>
    <div class="layui-input-block">
    <select name="l_bank">
    <option value="0">中国银行</option>
    <option value="1">中国建设银行</option>
    <option value="2">中国农业银行</option>
    <option value="3">中国工商银行</option>
    </select>
    </div>
    </div>

    <script id="demo" type="text/html">
    <div class="layui-form-item">
    <label class="layui-form-label">会员账号</label>
    <div class="layui-input-block">
    <input type="text" name="l_account" autocomplete="off" class="layui-input layui-disabled" value="{{= d.l_bank_account }}" disabled="disabled" >
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">会员级别</label>
    <div class="layui-input-block">
    <input type="text" name="l_user_level" autocomplete="off" class="layui-input layui-disabled" value="{{d.l_user_level == 1?'报单中心':'普通会员'}}" disabled="disabled">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">会员姓名</label>
    <div class="layui-input-block">
    <input type="text" name="l_user_name" autocomplete="off" class="layui-input layui-disabled" value="{{d.l_user_name }}" disabled="disabled">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">手机号码</label>
    <div class="layui-input-block">
    <input type="text" name="l_user_phone" autocomplete="off" class="layui-input layui-disabled" value="{{d.l_user_phone }}" disabled="disabled">
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">收货地址</label>
    <div class="layui-input-block">
    <input type="text" name="l_user_address" autocomplete="off" class="layui-input" value="{{# if (d.l_user_address == null) {''} }}">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">收货人姓名</label>
    <div class="layui-input-block">
    <input type="text" name="l_user_address_name" autocomplete="off" class="layui-input" value="{{d.l_user_name }}">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">收货人电话</label>
    <div class="layui-input-block">
    <input type="text" name="l_user_address_phone" autocomplete="off" class="layui-input" value="{{d.l_user_phone }}">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">开户银行</label>
    <div class="layui-input-block">
    <select name="l_bank" lay-filter="">
    <option value="0">中国银行</option>
    <option value="1">中国建设银行</option>
    <option value="2">中国农业银行</option>
    <option value="3">中国工商银行</option>
    </select>
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">开户行</label>
    <div class="layui-input-block">
    <input type="text" name="l_bank_account" value="{{d.l_bank_account }}" autocomplete="off" class="layui-input" placeholder="请输入开户行">
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">复选框</label>
    <div class="layui-input-block">
    <input type="checkbox" name="like[write]" title="写作">
    <input type="checkbox" name="like[read]" title="阅读" checked>
    <input type="checkbox" name="like[dai]" title="发呆">
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">银行卡号</label>
    <div class="layui-input-block">
    <input lay-verify="number" type="text" name="l_bank_cardNum" value="{{d.l_bank_cardNum }}" lay-verify="number" autocomplete="off" class="layui-input" placeholder="请输入银行卡号">
    </div>
    </div>
    <div class="layui-form-item">
    <div class="layui-input-block">
    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
    </div>
    </script>
    </form>
    </div>


    </div>
    </section>


    <script type="text/javascript" src="jsp/common/layui/layui.js"></script>
    <script type="text/javascript">
    layui.use('form', function(){
    var form = layui.form();
    alert(1);
    alert(JSON.stringify(form));
    layui.use('laytpl', function(){
    layui.use(['jquery'],function(){
    window.jQuery = window.$ = layui.jquery;
    $.getJSON("user/findById.do", function(data){
    // alert(JSON.stringify(data));
    var laytpl = layui.laytpl;
    var gettpl = document.getElementById("demo").innerHTML;
    laytpl(gettpl).render(data, function(html){
    document.getElementById("view").innerHTML = html;
    });
    });
    });
    });
    });

    </script>
    </body>
    </html>
    0 回复
  • @第一把菜刀 谢谢你 好了form.render();
    0 回复