+ Start a Discussion

Create a Record on click of Apex:InputCheckbox.

Please any help is welcome,Hi I would like to create a Record with the values captured/selected from radio button  once apex:Selectcheckbox is checked in Visualforce.Thank in Advance.

User-added image
Emmanuel Cruz BEmmanuel Cruz B
Hi Rashmi,

What you can do is use javascript to call a remoteAction method in the controller to save it or if you want to reRender a block, call an action function. Here a general example:

<apex:page controller="Ctrl">
    <!-- Option 1 -->
        <apex:actionFunction action="{!SaveRecord}" name="SaveRecord" reRender="oLabel"/>
        <apex:inputCheckbox value="{!readyToSave}" onclick="SaveRecord()"/>
        <apex:outputLabel value="{!saveResult}" id="oLabel"/>
    <!-- Option 2 -->
        function saveRecordJs(){
                function(result, event){
        <apex:inputCheckbox value="{!readyToSave2}" onclick="saveRecordJs()"/>

public class Ctrl
    public Account Acct {get;set;}
    public boolean readyToSave {get;set;}
    public string saveResult {get;set}
    public static Account Acct2 {get;set;}
    public static boolean readyToSave2 {get;set;}
    public Ctrl(){
    public void saveRecord(){
            insert Acct;
            saveResult  = 'Success!!';
        }catch(Exception e){
            System.debug('The following exception has occurred: ' + e.getMessage());
            saveResult = 'Fail';
    public static boolean saveRecordJs(){
            insert Acct2;
            return true;
        }catch(Exception e){
            System.debug('The following exception has occurred: ' + e.getMessage());
            return false;

Hope it helps you