BootStrap 智能表單系列 二 BootStrap支持的類型簡介


代碼如下(鏈接地址:https://github.com/xiexingen/Bootstrap-SmartForm/blob/master/demo/form1-basic.html):

<!DOCTYPE html>
<html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <title>基礎配置</title>
        <link rel="stylesheet" href="../css/bootstrap.css">
        <script src="../lib/jquery.js"></script>
        <script src="../lib/bootstrap.js"></script>
        <!--工具方法-->
        <script src="../scripts/global.js"></script>
        <!--插件-->
        <script src="../scripts/plugin.js"></script>
    </head>
    
    <body>
        <div class="panel panel-default">
            <div class="panel-heading"><label>基礎配置</label></div>
            <div class="panel-body">
                <form action="#" id="formContainer" class="form form-horizontal"></form>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading"><label>介紹</label></div>
            <div class="panel-body">
                <h3>支持的表單元素包括:text、select、radio、checkbox、datetime、search、textarea、自定義</h3>
            </div>
        </div>
        <script>
            $(function () {
                var eles=[
                        {ele:{type:'text',name:'UserName',title:'用戶名:'}},
                        [
                            {ele:{type:'radio',name:'sex',title:'性別:',items:[{text:'男',value:1},{text:'女',value:2}]}},
                            {ele:{type:'checkbox', name:'plant',title:'使用平台:',items:[{text:'APP',value:'app'},{text:'web',value:'web'}]}},   
                        ],
                        {ele:{type:'select',name:'province',title:'省份:',withNull:true,items:[{text:'廣東',value:'GD'},{text:'湖南',value:'HN'}]}},
                        {ele:{type:'datetime',name:'FromeDate',title:'有效期:'}},
                        {ele:{type:'search',name:'selectName',title:'選擇:'}},
                        {ele:{type:'textarea',name:'address',title:'地址:'}},
                        {ele:{pre:{text:'<input type="radio" />'},type:'text',name:'pre',title:'叉前面:'}},
                        {ele:{next:{text:'<input type="radio" />'},type:'text',name:'next',title:'叉后面:'}},
                        {ele:{pre:{text:'<input type="checkbox" />'},next:{text:'$'},type:'text',name:'pre&next',title:'前后皆叉:'}},
                ];
                //隱藏表單元素主要用於編輯時候后台可以區別開來
                var hides = [{ id: 'GUID' }];
    
                var bsForm = new BSForm({ eles: eles, hides: hides, autoLayout:true }).Render('formContainer');
            });
        </script>
    </body></html>

主要是下面的js那一塊,通過該段js生成form表單

 

運行效果圖: 

得到如圖所示的結果

 

上一章:BootStrap智能表單系列 一 Demo示例

下一章:BootStrap 智能表單系列 三 分塊表單配置的介紹

本系列首頁:BootStrap 智能表單系列 首頁 (已完結)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM