Expand my Community achievements bar.

SOLVED

Question on Using Radio Button Value to Populate a Text Field

Avatar

Level 4

i have a series of radio buttons on the first page of a form. Based on the series selection, i want to populate a text field on page 7 of the form. I am using this code to successfully populate the field:

if (this.rawValue == "1"){

     this.resolveNode("form1.Requisition_Page7.#subform[0].Period").rawValue = "July 1 - September 30"

}

This code is in Javascript in the change event of the radio button list. What i am asking is there a way to add the year to the text box output (which will vary). The user selects the year from a dropdown list, also located on page 1.

I know how to use concat and make this work in FormCalc, but do not know how to do this in Javascript. I want the field to read "July1, 2019 - September 30, 2019 (if 2019 is the year selected in the dropdown box).

I have many other instructions in the change event and do not wish to convert all of it to FormCalc. Any help would be appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi,

You would still use simple concatenation in Javascript but you need to specify the dropdownlist's raw value.

Example:

this.resolveNode("Requisition_Page7.Period").rawValue = "July 1" + ", " + DropDownList1.rawValue + " - September 30" + ", " + DropDownList1.rawValue;

1492319_pastedImage_1.png

Notes:

  • The DropDownList contains the years.
  • You have to consider the order in which things are selected/clicked.
    If you click the radio button first and then select the year, you would get the result below. This is because the code triggers on clicking the radio button. Effectively, after clicking the radio button, the selection of the dropdownlist does nothing. It shows null, because that was what the dropdownlist shows by default.
    As backup you could do a few things, the selection of the dropdownlist could be used to trigger the code as well, or more simply, disable the radio button and enable it AFTER a dropdownlist selection has been made (you could enable on the exit code). This will ensure that a year is selected first.

1492320_pastedImage_2.png

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

Hi,

You would still use simple concatenation in Javascript but you need to specify the dropdownlist's raw value.

Example:

this.resolveNode("Requisition_Page7.Period").rawValue = "July 1" + ", " + DropDownList1.rawValue + " - September 30" + ", " + DropDownList1.rawValue;

1492319_pastedImage_1.png

Notes:

  • The DropDownList contains the years.
  • You have to consider the order in which things are selected/clicked.
    If you click the radio button first and then select the year, you would get the result below. This is because the code triggers on clicking the radio button. Effectively, after clicking the radio button, the selection of the dropdownlist does nothing. It shows null, because that was what the dropdownlist shows by default.
    As backup you could do a few things, the selection of the dropdownlist could be used to trigger the code as well, or more simply, disable the radio button and enable it AFTER a dropdownlist selection has been made (you could enable on the exit code). This will ensure that a year is selected first.

1492320_pastedImage_2.png