Recently I had the requirement of showing or hiding both the label and input item, depending on the selection within a select list.
Otherwise, display the items and as an added bonus - set the label to the value of the selected list item.
So this would be added to the page footer text:
- $f_Hide_On_Value_Item is a pre-defined function you can call to hide a list of items based on the value of another. Its behaviour is documented online here. In this case I listed both the label I created an id for plus, the item name - surrounded by square brackets as to define an array.
- 'hide_desc' is the value I've set in this case when the input description is '- Select me'
- .innerText allows me to set the descriptive label, as long as I supply the id I defined for the label, not the item name you see in the Apex builder.
- The highlighted line 9 means the function will be called when you open the page, in this case after it's rendered. That way the fields will be shown/hidden depending on the set value in the select list.
So the final product will change the label to the selected value in the select list, or hide the label and input field if '- Select me -' is chosen.