zoukankan      html  css  js  c++  java
  • dojo中DateTextBox日期格式yyyy-MM-dd转化为数据库中yyyyMMdd

    1、问题描述

          在dojo中,日期格式是yyyy-MM-dd,即页面上显示的日期格式;现在,数据库中的日期格式是yyyyMMdd,需要转化一下

    2、问题思路

    (1)首先,取DateTextBox中的值;

    (2)然后,将DateTextBox中显示的值进行截取;

    (3)最后,进行字符串组合,组合需要的日期格式。

    3、解决步骤

    (1)取值

    var startDateStr = dijit.byId("startDate").get('displayedValue');
    (2)截取

    startDateStr.substring(0,4)
    startDateStr.substring(5,7)
    startDateStr.substring(8,10)
    (3)拼接

    var startDate = startDateStr.substring(0,4)+startDateStr.substring(5,7)+startDateStr.substring(8,10);

    4、运行结果

    (1)初始化




    (2)点击查询


    5、页面源码

    <!DOCTYPE html>
    <!--
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    -->
    <html>
        <head>
            <title>TODO supply a title</title>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width">
            <link  rel="stylesheet" href="../script/dojoroot/dijit/themes/claro/claro.css"/>
            <script type="text/javascript" src="../script/dojoroot/dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script>
        </head>
        <body class="claro" role="main">
            <div id="div_body">
                <table>
                    <tr>
                        <td>
                            <label for="startDate" style="color:#FF0000; font-weight:bold;">统计日期:</label>
                            <input type="text" id="startDate" data-dojo-id="startDate" data-dojo-type="dijit/form/DateTextBox"
                                  data-dojo-props='type:"text", name:"startDate", required:true,
    			      onChange:function(){ dijit.byId("endDate").constraints.min = this.get("value"); },
                                  constraints:{datePattern:"yyyy-MM-dd"} '/> 
                        </td> 
                         <td>
                             <button type="button" id="search" data-dojo-type="dijit/form/Button">查询
                                 <script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
                                     var startDateStr = dijit.byId("startDate").get('displayedValue');
                                     var startDate = startDateStr.substring(0,4)+startDateStr.substring(5,7)+startDateStr.substring(8,10);
                                     alert("统计日期:" + startDate);
                                 </script>
                             </button> 
                        </td>
                    </tr>
                </table>
            </div>
        </body>
    </html>
    


        

  • 相关阅读:
    使用 git 托管代码
    转载自网络大神
    i18n 国际化
    转自知乎大神---什么是 JS 原型链?
    转自知乎大神----JS 闭包是什么
    转自知乎大神----JS 的 new 到底是干什么的?
    转载自知乎大神---this 的值到底是什么?一次说清楚
    sql查看本机IP地址
    Python 编码规范(Google)
    Python在mysql中进行操作是十分容易和简洁的
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315464.html
Copyright © 2011-2022 走看看