Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Make a field visible

Avatar

Former Community Member
I have a RadioButtonList with Yes and No as the values. If a user selects yes I want a textbox to appear. I have tried two different click events on the Yes button and haven't had any luck. I have never done any developing before so I am a complete newbie.



first event:

var myDoc = event.target;

var D = myDoc.getField("form1[0].#subform[0].NewFields[0].Description[0]");

D.presence = "visible";



second event:

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

form1[0].#subform[0].NewFields[0].Description[0].presence = "visible";}



Can anyone provide me with some assistance. Thanks!
3 Replies

Avatar

Former Community Member
In the hierarchy view the two RadioButtons are underneath a group object. Highlight that group object (RadioButtonList)and then write this code on the exit event of that object:



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

D.presence = "visible"

} else {

D.presence = "invisible"

}



The "this" connotation refers to the object that has focus (in our case the RadioButtonList). Note that this is javascript and that your form must be dynamic to have objects appear and disappear programmatically.

Avatar

Former Community Member
Thanks for your help! I added the code to the exit event and I also re-saved the form as a Dynamic form but the field is still not disappearing. I do not get any errors in the debugger. My code now looks like this:



var myDoc = event.target;

var D = myDoc.getField("form1[0].#subform[0].NewFields[0].Description[0]");

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

D.presence="visible"

}else{

D.presence="invisible"

}



Any Suggestions?

Avatar

Former Community Member
Add this line of code for debugging before the if statement.



app.alert(this.rawValue)



It will return the value of the RadioButtonlist.