Adding Seven Days to the End Date After Editing the Start Date by JS

  • Last update:June 04, 2025
  • Overview

    Application Scenario

    You have two date widgets, one for the start date and the other for the end date. To query data in a week, you may want to set the end date to seven days after the start date automatically after selecting a start date. The following figure shows the actual effect.

    Implementation Method

    You can add an After Editing event to the start date and use JavaScript to set the end date to seven days after the start date.

    Example

    Event Adding

    Enter the editing page of the parameter panel, select the starttime widget, and add an After Editing event, as shown in the following figure.

    The JavaScript code is as follows.

    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);

    Effect Display

    Save the template, and click Pagination Preview. The following figure shows the effect.

    iconNote:
    The effect cannot be previewed on mobile terminals.

    Template Download

    Attachment List


    Theme: Parameter
    • 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