+ Start a Discussion
vamsi krishna 106vamsi krishna 106 

Is it ok to call the action and onclick event on command button at a time in visualforce..?

hey guys please help..this..
<apex:commandbutton action="{!page2}" onclick="return conrimnew(event)" value="confirm"/>

but here i need to open one confirm box..if it is ok then i need to execute the apex method .please help me guys..for first time it's working good..but  at first time if i cancel and then for next time if i ok..i am not able to call the apex method..please help me.guys..


Best Answer chosen by vamsi krishna 106
Antonio ManenteAntonio Manente
In this situation I'd use an <apex:actionFunction>.. For example:
//Your command button
<apex:commandButton onclick='confirmThis(event)'/>

//use this to invoke your apex method
<apex:actionFunction name='callMethod' action='{!page2}'/>

function confirmThis(event){

Hope this helps!