Show/hide fields based on value of another field

I want to show or hide a few fields based on the value of another field. I have it working correctly when the field value is changed by using client side events for that field.

{ 
	"change": function(e) {
          if (this.value == "XX") {
             $(this).fields("fieldA").visible(true); 
             $(this).fields("fieldB").visible(false);
           } else if (this.value == "YY") {
             $(this).fields("fieldA").visible(false); 
             $(this).fields("fieldB").visible(true);
	}
}

However, I don’t know how to hide the fields initially on the Edit page based on the value before the change.

hi,if ($(“#x_FIELD”).val() == “VAL”) $(“#r_FieldToHide”).hide();

That worked. Thank you very much.
Todd

I’m trying to do the same thing, where are you putting this code? What event?

You may put the code in the first post above from Fields setup → Edit Tag pane → Client side events.You may put the code in the second post above from Client Scripts → Table-Specific → Add/Copy Page and/or Edit Page → Startup Script.