function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
deepakMdeepakM 

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.

deepakMdeepakM

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