JS Get the number in the string

  • Last update:December 15, 2020
  • I. Overview

    1.1 Problem

    When making a report, sometimes it is necessary to directly obtain the number in the string, as shown in the following figure:


    1.2 Solution

    This can be realized by adding JS click event to the button.

    Note: This function does not support mobile devices.

    II. Example

    2.1 Report Design

    Create a new built-in dataset Embedded1, as shown in the following figure:

    Design the table as shown below, add [Button Widget] to cell B2.


    2.2 JS event

    1. Select cell B2, click the [Event] tab, and add a [Click] event to the button widget.

    2. Add parameter A, select the type of Value [formula], and enter A2.

    3. Add the following JS:

    var num= A.replace(/[^0-9]/ig,"");
    var location = this.options.location;
    var cr = FR.cellStr2ColumnRow(location);
    var col = cr.col; 
    var ro = cr.row; 
    contentPane.setCellValue(1,ro,num);


    2.3 Preview effect

    Save the report, click [Data Entry Preview], and click the button to get the numbers in the other string.

    III. Download template

    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    9s后關閉

    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