+ Start a Discussion
TuxTux 

How to disable a button on a page layout, if some checkbox is selected?

I have a custom field defined in my Opportunity standard object. It is a checkbox. When I view the details for a particular opportunity, if the checkbox is selected, I do not wish to show the custom button on the layout. However, if it is not selected, I want to show the button and execute apex code, the source of which is a VF page. 

 

How is that possible? Tried to edit the layout, but could not find anything there.

TuxTux

At the moment, this is how I am doing it. By selecting the source as Onclick Javascript, and behaviour as Javascript.

 

{!IF(Opportunity.Mail_after_appointment_is_confirmed__c, 
    "this.disabled=true;this.className = 'btnDisabled';",
    "window.alert('unticked')")}

 But the catch is, the button is disabled, after I click on it. I want it to be disabled, when the layout loads.

kiranmutturukiranmutturu

do u want the button to be in disabled state in the pageload right?

 hope you are using commandbutton the use the disabled property and control the disable property based on the requirement like

 

onlaod..

 

controller:

boolean blnflag =  true; 

public void setblnflag(boolean value){

 value = false;

}

public boolean getblnflag(){

 return blnflag;

}

 

page:

 

<apex:commandbutton disabled="{!blnflag}"/>


TuxTux

Sorry I did not make the question clearer. I am using the detail page layout, not an Apex page.

kiranmutturukiranmutturu

in the standard page you can't acheive this kind of scenario because where we dont have any control on the repesctive dom objects of that form....but one soultion is there through homepage components u need to write a javascript code to make this..but that is not at all suggestable....

TuxTux

Alright. I guess I should alert the user that the option is already checked. Although that is counter-intuitive to a UI. 

kiranmutturukiranmutturu

hope that is the best soultion ....

bob_buzzardbob_buzzard

TehNerd posted up an example of how manipulate buttons via the sidebar at:

 

http://www.tehnrd.com/show-and-hide-buttons-on-page-layouts/