JS Automatically Set the End Date as 7 Days after the Start

  • Last update:  2020-12-15
  • I. Overview

    1.1 Requirement

    The Start Date widget and the End Date widget are used to query data collected within a week. When the Start Date is picked, the End Date is always 7 days greater than the Start Date by default. The actual effect is shown as below:

     


    1.2 Solution

    Add an Edit End event to the Start Date. Use JavaScript to set the End Date 7 days greater than the Start Date.

    II. Sample

    2.1 Add an event

    In the Edit Parameter Interface, select the starttime widget and add an Edit End event. See the demonstration below:

     

    Input the following JavaScript codes:

    var date1=new Date(this.getValue());
    var date2= new Date();date2.setTime(date1.getTime()+(7*24*60*60*1000));
    this.options.form.getWidgetByName("endtime").setValue(date2);

     

    2.2 Preview

    Save the template and click [Pagination Preview]. The preview effect on a PC is shown as below:

     

    III. Download the template

    Attachment List


    Theme: Report Application
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy