You need to sign in to do that
Don't have an account?
Shiv Shankar
what is the use of return statement on onlclick event
Hi Friends,
What is the use of return statement here
<apex:commandButton action="controllerMethod()" onclick="return javaScriptMethod()" />
SUMMARY :
So if you add a onclick="return false;" the command button will never execute the controller method
Hi,
The use of return is that if the javascript method returns true value then it will be executed and do the operation, else if it retiurns false value then it will do nothing and keep the same page.
For e.g while clicking 'OK' and 'CANCEL' we are using return. When we click Cancel then javascript method will return false and keep in the same page and don't call the controller method.
If we don't use return then it will return true by default.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Ok, just see following scinario...
I have this command link in my vf page
I have this java script
- What is happening
1. when i click on add to basket link without selecting any item it shows error. which is right. and i am returning the false because i don't want to execute action metod in this case.
2. when i click on add to basket link after selecting item it doesn't show any error, alert(1) also coming in to the picture, i am returning ture also to execute theaction method... but it doesn't call action method.
3. when i remove reRender attribute from command link it calls action method but it refreses the whole page, which i don't want.
please help it's urgent..
I mean hardcode just return true. Does that calls the controller method ?
Since it is urgent.
I would suggest a workaround.