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
Lukesh KarmoreLukesh Karmore 

why the code not working

can any one help me to clear the error
Thank you

public  class ActionFunctionTest
{
   public string myVar{get; set;}
    public void showValue(){
        myVar='hey Lukesh How are you';       
    }
    }
    
<apex:page controller="ActionFunctionTest">
<apex:form>
    <apex:actionFunction Name="myAction" action="{!showValue}" reRender="out" />
    
    <apex:commandButton value="click me"  onclick="myfunction(); result false"/>
    <br/>
    <apex:outputPanel id="out">
     { !myVar}
    </apex:outputPanel>

    <script>
    function myfunction(){
    myAction();
    }
    </script>
</apex:form>
</apex:page>
AnudeepAnudeep (Salesforce Developers) 
Hi Lukesh, 

Tried your code in my org, I don't see any error

Can you please provide the exact error message you are seeing? Thanks
Lukesh KarmoreLukesh Karmore
hello Anudeep,
when i click the button ,didn't get any response.
AnudeepAnudeep (Salesforce Developers) 
Hi Lukesh, 

I suggest taking a look at the following example
 
<apex:page controller="exampleCon">
<!-- Add the onclick event listener to a panel. When clicked, the panel triggers
    the methodOneInJavascript actionFunction with a param -->
    <apex:outputPanel onclick="methodOneInJavascript('Yes!')" styleClass="btn"> 
        Click Me 
    </apex:outputPanel>
    <apex:form>
    <apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="showstate">
        <apex:param name="firstParam" assignTo="{!state}" value="" />
    </apex:actionFunction>
    </apex:form>
</apex:page>


In the above visualforce page javascript method in the onclickevent will call the apex controller method with the help of actionfunction.
Apex controller. With the help of actionfunction we can make a call to the apex controller class
 
/*** Controller ***/
public class exampleCon {
    String uname;

    public String getUsername() {
        return uname;
    }
            
    public PageReference sayHello() {
        uname = UserInfo.getName();
        return null;
    }
            
    public void setState(String n) {
        state = n;
    }
            
    public String getState() {
        return state;
    }
            
    public PageReference methodOne() {
        return null;
    }
            
    private String state = 'no';
}

I suggest implementing based on this example