JS Assigns Multiple Values to Text Box

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

    1.1 Problem description

    For the Data Entry template, it is hoped that the data of a certain cell will be multiple values of a certain column in the database table (the same value may appear multiple times), and the display order can be customized. For example, the values in the database are 'A','B' ,'C' and 'D', and it is hoped that 'A, B, A' will be displayed in the text box, with the effect shown below. How to achieve this?

    1.png

     

    1.2 Implementation ideas

    Add a post-edit event to the drop-down box widget, so that every time a value is selected in the drop-down box, the value is spliced to the original content of the text box.

    You will learn
    • Examples

      • Template design

      • Set the data dictionary of the drop-down box

      • Add a post-edit event

      • Preview

    • Download the template

    II. Examples

    2.1 Template design

    Add a drop-down box widget and a text widget, as shown below:

     

    2.2 Set the data dictionary of the drop-down box

     

    2.3 Add a post-edit event

    Add a post-edit event for the drop-down box widget

     

    The specific JS code is as follows:

    var value=this.getValue();//get current value
    var text=contentPane.curLGP.getCellValue("B2");
    //get the value of the text widget cell
    if(value!=""){
    if(text == "" || text == null){
    //if text widget value is null, assign the current value to text widget cell
    contentPane.setCellValue("B2",null,value);
    }else{//if the text widget has value, append it with old value
    contentPane.setCellValue("B2",null,text+","+value);
    }
    }

    2.4. Preview

    Save the template, click Data Entry Preview, and the effect on PC terminal is as follows:

    5.gif 

    Note: In our testing, the mobile terminal does not support this JS.

    III. Download the 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