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
Saurabh Sood 12Saurabh Sood 12 

Actionfunction value is not comming

Hi everyOne,

I have written first actionfunction code but it not calling to that scipt method as it supose to do so can anyone help me out withthis

This is my controller 
public class wrapperWithRadioButtonCtrl {
    List<Account> acc{get;set;}
    Public Integer records{get;set;}
    public String passedValue{get;set;}
    public wrapperWithRadioButtonCtrl(){
        acc = [select id, name, type from Account limit 10];
        records = acc.size();
        System.debug('Total records are '+ records);
        passedValue ='';
    public List<Account> getaccounts(){
        return acc;
    public pageReference dummyCall(){
        return null;

Visualforce page

<apex:page Controller="wrapperWithRadioButtonCtrl" readOnly="true" >
   <apex:form >
       <script src=""></script>
        function MyFunction(){
            var i = {!records};
            var selectedRecordIds;
           for(j = 0; j < i; j++){
               console.log('value of j'+ j+'\n');
                selectedRecordIds = document.getElementByName("SelectedAccount")[j].value;   
                  console.log('selected Record Id is'+ selectedRecordIds);
    <apex:pageBlock >
            <Tr><th>Selected Account</th>
            <th>Account Name</th>
            <th>Account Type</th>
            <apex:repeat value="{!accounts}" var="a" >
                <td><input type="radio" value="{!}" name="SelectedAccount"/> </td>
                <td><apex:outputText >{!}</apex:outputText></td>
                <td><apex:outputText >{!a.type}</apex:outputText></td>
    <apex:actionFunction name="passVariableToController" action="{!dummyCall}" reRender="pd2">
        <apex:param name="pi" assignTo="{!passedValue}" value="" />
    <apex:commandButton onclick="MyFunction(); return false;" value="Search" />
        <apex:pageBlock id="pb2" title="Account Value">
            <apex:outputText >{!passedValue}</apex:outputText>
Prosenjit Sarkar 7Prosenjit Sarkar 7
Hi Saurabh, 

Replace the line   var i = {!records}; with , 

var i = '{!JSENCODE(records)}';