Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

text field presence and radio buttons

Avatar

Level 1

New to LC and JavaScript and am attempting to show/hide a text field on radio button (excl group) select using the presence property. Two buttons in the exclusion group (i'll call them 1 and 2), default presence of text field is to be hidden (not displayed and takes up no space on layout).  I've set the default value for the radio button group to "2" and would like the text field to show (and have focus, but i've managed that bit) when the value changes to "1" on click, then clear and hide again if "2" is clicked.  Any advice would be greatly appreciated.

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Employee

You can use this script on the click event of the exclusion group:

 

form1.#subform[0].rbl::click - (JavaScript, client)

if (this.rawValue == "1")
{
TextField1.presence = "visible";
}
else
{
TextField1.presence = "hidden";
}

// That should do it, because rb1 has a value of 1, and rb2 has a value of 2. rbl == exclusion group.

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

You can use this script on the click event of the exclusion group:

 

form1.#subform[0].rbl::click - (JavaScript, client)

if (this.rawValue == "1")
{
TextField1.presence = "visible";
}
else
{
TextField1.presence = "hidden";
}

// That should do it, because rb1 has a value of 1, and rb2 has a value of 2. rbl == exclusion group.