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

How to send parameters to apex method on button click in visualforce page
HI everyone.
i need to know how we can send a parameters to apex method .as my button like below
<apex:commandButton action="{!save}" onclick="return confirm('are you sure?');" value="TSave" />
As when we hit the ok ,we need to send a parameter to the save action .
Please help me.
Thanks.
thats my code in page
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
<apex:actionFunction name="CallApexMethod" action="{!Save}">
<apex:param name="key" value="val"/>
</apex:actionFunction>
i call in onload as
<script type="text/javascript">
$(document).ready(function(){
if({!chkConfirm})
{
if (confirm('There are not enough miles in that account. Are you sure you want to continue?'))
{
alert("2");
CallApexMethod() ;
return false;
}
}
else
{
}
});
</script>
and i apex page i did
System.debug('TestMessage: '+ ApexPages.CurrentPage().getParameters().get('key'));
but not get the param.
pleas let me know where i go wrong.
thanks