function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TGHTGH 

Hiding Text Box Unless Checkbox is Selected

Hi,

 

I'm trying to find a solution to hide a text box is a checkbox is checked. This is very similar to the dependent field relationships for picklists, but that feature isn't active for other field types. I thought I could build this using the following javascript, but no such luck. Whenever I try to create a new record, I can still see the dependent text field whether the checkbox is checked or not. Strangely, my syntax gives me no errors (it just doesn't do anything).

 

Here's my code:

 

<script>
<!--
function c(){}


function test(){
if({!Product2.Royalty__c}.checked){
{!Product2.Royalty_Vendors__c}.style.visibility="visible"
}
else{
{!Product2.Royalty_Vendors__c}.style.visibility="hidden"
}
}
//-->
</script>

JakesterJakester
Pretty sure this is only possible by building a whole new page in Visualforce. It's probably not worth it for the effort. Most people just add a validation rule that doesn't allow a field to be filled in until a checkbox is checked.
TGHTGH
Yeah, that's a possibility, but then the checkbox is visible anyway. Salesforce looks to have this feature added sometime this year (or did in a post on the ideas boards last year anyway).
MK B. FlemingMK B. Fleming

Has anyone figured out how to do this?  I work for a non-profit that supports over 300 inner-city schools in the New York City area.  Many of our Employees and Patrons are on various School Boards, scholarship endowment committees, Foundation committees, etc.  I really need this hidden picklist functionality!  Help!

MK B. FlemingMK B. Fleming

How would I write that rule?