I am trying to update the checkbox(checked or unchecked) in the database from the UI. I am calling the js function on onclick of checkbox and invoking controllers action but I am getting this error.

public class CheckboxFunctionality 
    public List<Account> accList{get;set;}
    public String recordId{get;set;}
    public CheckboxFunctionality()
        accList = new List<Account>();
        accList = [Select id, name, phone, isActive__c  From Account Order By LastModifiedDate Limit 5];

    public PageReference checkActive()
        Account acc = new Account();
        acc.id = recordId;
        if(acc.isActive__c == true)
            acc.isActive__c = false;
            acc.isActive__c = true;
        update acc;
        return null;

    <apex:page controller="CheckboxFunctionality">
        <apex:actionFunction name="callAF" action="{!checkActive}" reRender="pbt">
            <apex:param id="accId" value="" assignTo="{!recordId}"/>
            <apex:pageBlockTable value="{!accList}" var="row" id="pbt">
                <apex:inputField value="{!row.isActive__c}" onclick="check('{!row.Id}')"/>
                <apex:column value="{!row.name}"/>
                <apex:column value="{!row.Phone}"/>
        function check(recId)


Uncaught SyntaxError: Unexpected token :

this is coming in console.


Give your apex:param name attribute. So it will work.

<apex:actionFunction name="callAF" action="{!checkActive}" reRender="pbt"> <apex:param name="apparam" id="accId" value="" assignTo="{!recordId}"/> </apex:actionFunction>

This will not give you compile time error but name is the required attribute of apex:param tag

  • thanks for the reply its working now. But now in my controller only else condition is working I dint know why its happening
    – Anzar
    Oct 23 '16 at 5:12
  • @Anzar because you create a new instance of Account and acc.isActive__c you never set thi so this will always be false. Also if this works for you then you can accept this answer. Oct 23 '16 at 5:31
  • sure, I got it how I could I rectify it
    – Anzar
    Oct 23 '16 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.