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
TarentTarent 

Hide Custom Field On Button Click on Visualforce Page

hi

 

Please tell me that How to hide the custom field on button click  on VF Page.

Best Answer chosen by Admin (Salesforce Developers) 
SRKSRK

<script>

function hidefield()

{

 document.getElementById("fieldIDtobehide").style.dispaly = "none";

 return false;

}

</script>

<apex:commandbutton onclick="return hidefield();"/>

<input type="text" id ="fieldIDtobehide" />

All Answers

bvramkumarbvramkumar

Create a boolean property in your controller and assgin "true" initially.

public boolean showField{get;set;}

 

Bind this to the rendered attribute of the custom field rendered="{!showField}"

 

Onclick of the button, call a function in controller to make the showField property to false; and keep the rerender attribute of the button equal to your Customfield Id.

 

SRKSRK

<script>

function hidefield()

{

 document.getElementById("fieldIDtobehide").style.dispaly = "none";

 return false;

}

</script>

<apex:commandbutton onclick="return hidefield();"/>

<input type="text" id ="fieldIDtobehide" />

This was selected as the best answer