AnsweredAssumed Answered

How to hide a field based on the value of another field

Question asked by hiten.rastogi on Sep 4, 2017



I have a type with two fields(program and author), program field is a drop down and contains NHC, TMCC and OTHERS as the value. I want that when the user select OTHERS in the program field the author field should not be shown in edit, create and view form mode.


Below is what I tried to do.

I copied the textfield.ftl into my custom ftl author-controller.ftl(author-controller.ftl - )  and created a small javascript that will capture the value of program field and based on that try to hide the author field.


For now I am concentrating on hiding the author field in view mode but not able to. I try to get the id of the author field div and hide it but in the console I can see that document.getElementById("${fieldHtmlId}").style.display = 'none'; return null.


Please let me know how I can achieve it.




Hiten Rastogi