You need to sign in to do that
Don't have an account?

Adding "Are you sure you are ok?....." confirmation on a button
Hi,
I have a button that will update a field on an object. I want to do it only when the user clicks the "OK/YES" button on the confirmation window.
How can I achieve this in in visual force.
My sample starting code as follows:
--------------
<apex:page Controller="UpdateOutboundFlag" tabStyle="Master_Config__c">
<!-- Begin Default Content REMOVE THIS -->
<apex:ListViews type="Master_Config__c" />
<apex:form >
<apex:pageBlock >
<apex:commandButton action="{!save}" value="Update config info." id="theButton" onclick="var x=window.confirm('Are you sure you are ok?')
;"/>
</apex:pageBlock>
</apex:form>
</apex:page>
___________________
Write Javascript function and put this line to that function and compare the variable value to
'Yes' or 'No' if its Yes the return true and vice versa.
var x=window.confirm('Are you sure you are ok?
and make function call from the button like
onclick = ' return name_of_the_function()'
I hopw this will work for you
Thanks Sandip458
I am trying to update a certain field in a salesforce object - based on user's confirmation(Yes).I am trying to do something of following kind but no success..
______________________
<apex:page Controller="UpdateOutboundFlag" tabStyle="Master_Config__c">
<!-- Begin Default Content REMOVE THIS -->
<apex:ListViews type="Master_Config__c" />
<apex:form >
<apex:pageBlock >
<apex:commandButton value="Export all config info." id="theButton" onclick="var r=confirm('Are you sure?'); if (r==true) {var updateMasterConfig = new sforce.SObject('Master_Config__c'); var masterConfigs = [SELECT Id, Export_Flag__c FROM Master_Config__c LIMIT 1]; var configs = masterConfigs.getArray('records'); if (configs.length == 1) {updateMasterConfig.Id=configs[0].Id; updateMasterConfig.Export_Flag__c='True';} var updateResult=sforce.connection.update([updateMasterConfig]);}" />
</apex:pageBlock>
</apex:form>
</apex:page>
______________________
I need to prevent updating the Export_Flag__c field in Master_Config__c if the 'Are you sure' answer is No
lvivanin!!!