Skip to main content
keerthanm0001
July 19, 2023
Question

Dropdown and text field linking

  • July 19, 2023
  • 3 replies
  • 0 views

I have a dropdown field   called "Name" which has 3 values chintan, mantan and other

when the user selects other, a text field will be visible in which he can fill the other name.

the value entered in text field (other name)should get saved into name field 

how can I achieve this?

    3 replies

    July 19, 2023

    Hi,

    You can put a show when condition that when dropdownValue="Other" then a text field will show. In the text field you can map the rule input to save data where name is getting stored. Make sure to stored both the dropdownValue and text field value in different variable. 

    July 19, 2023

    a!localVariables(
      local!list: { "Ramesh", "Somesh", "Other" },
      local!selectValue,
      local!otherValue,
      {
        a!dropdownField(
          label: "Name",
          choiceLabels: local!list,
          choiceValues: local!list,
          value: local!selectValue,
          saveInto: local!selectValue,
          placeholder: "Select a Value"
        ),
        a!textField(
          label: "other",
          showWhen: local!selectValue = "Other",
          value: local!otherValue,
          saveInto: {
            local!otherValue,
            if(
              contains(
                touniformstring(local!list),
                tostring(local!otherValue)
              ),
              "",
              a!save(
                local!list,
                append(local!list, local!otherValue)
              )
            )
          }
        )
      }
    )

    July 19, 2023

    Hi, You can use below code 

    a!localVariables(
              local!Choicevalue: {1,2,3},
              local!values,
              local!OtherName,
    a!sectionLayout(
          contents: {
               a!dropdownField(
                    label: "Name",
                   placeholder: "select a name",
                   choiceLabels: ri!DropDownValues,
                   choiceValues: local!Choicevalue,
                   value: local!values,
                   saveInto: local!values
      ),
    a!textField(
             label: "Name",
             value: local!OtherName,
             saveInto: local!OtherName,
             showWhen: if(tointeger(local!values)=3,true(),false())
        )
      }
     )

    )

    Here, I have made one rule input for dropdown field and use a local!values for saving the dropdown values, 

    And in text field you can use showwhen when other option is selected then text field show other it can't show.