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
Eelco LitjensEelco Litjens 

auto select checkbox in VF page

I would like to auto-select a checkbox .....i am not so well known with code.
is this something i can use?  How must i write this?
<apex:actionFunction value="{!item.Alert_SMS_sent__c}" immediate="true" />

 
sandeep sankhlasandeep sankhla
Hi Eelco,

what is the condition for autoselect ? you can set the attribute using 
selected = true if using apex:checkbox...based on your condition you an do this...if on load itself you want that checkbox to be checked then you can put selected=true...

Please check adn let me know if it helps.

Thanks.,
Sandeep
Eelco LitjensEelco Litjens
Hi Sandeep, when we press this button, a sms is sent to a contact, and i want to default select the checkbox to selected when sms is sent.
thanks 
sandeep sankhlasandeep sankhla
Okay then you can simply get the checkbox id in javascript and set the attribute selected=true adn rerender that...

1. After pressing the button in code you can get the checkbox DOM like

<apex:checkbox id='Test' value="{!}"/>

you can get like document.getElementById('Test').selected =true;

Like that you can set the attribute anytime you want..

Thanks,
Sandeep
Eelco LitjensEelco Litjens
ok, if i understand correctly, i do this?:
<apex:checkbox id='Test' value="{!item.Alert_SMS_sent__c}"/>
            document.getElementById('test').selected = true;
i don't understand the logic of the code, so if you could provide me woth the right code, that would be great.
 
sandeep sankhlasandeep sankhla
Hi,

This is the action function which does the processing when we click on button right..so oncomplete of this button you need toi call one javascript method where you will get nad set the value

<apex:actionFunction value="{!item.Alert_SMS_sent__c}" immediate="true"  oncomplete="setCheckboxValue();"/>

define once function in javascript

<script>

function setCheckboxValue()
{
      document.getElementById('Test').Selected = true;

}
</script>

here test is that checkbox id..
Please check adn let me know if it helps you..
Thanks,
Sandeep
Eelco LitjensEelco Litjens
Hi Sandeep,
many thanks. where do i put this? in the VF page? or seperately somewhere? if i put this in the VF page i get error Error: Unsupported attribute value in <apex:actionFunction> in SendSMS at line 13 column 120
<apex:page tabStyle="Contact" controller="SendSMS" action="{!iniciaMisto}">
  <apex:form >
  
    <apex:sectionHeader title="Mass" subtitle="Send SMS" />
    <apex:pageMessages escape="false"/>
    <br/>
  
    <apex:pageBlock >
    <apex:pageBlockSection title="Contact List" columns="1" collapsible="false">
        <apex:pageBlockTable value="{!conList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.MobilePhone}"/>
            <apex:actionFunction value="{!item.Alert_SMS_sent__c}" immediate="true"  oncomplete="setCheckboxValue();"/>

define once function in javascript

<script>

function setCheckboxValue()
{
      document.getElementById('item.Alert_SMS_sent__c').Selected = true;

}
</script>

        </apex:pageBlockTable>
        <apex:pageBlockTable value="{!leaList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.MobilePhone}"/>
        </apex:pageBlockTable>
        <apex:pageBlockTable value="{!DeeList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.Mobile_phone__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlockSection>
    
    
    <apex:pageBlockSection title="Select SMS Template" columns="1" collapsible="false">
        <apex:selectList value="{!useThisTemplate}" size="1" title="Choose a template" >
            <apex:actionSupport event="onchange" rerender="textSection" action="{!changeTemplateText}" />
            <apex:selectOptions value="{!TemplateSelectOptions}"/>
        </apex:selectList>
        
        <apex:pageBlockSection id="textSection" columns="1" collapsible="false" title="SMS Text">   
            <apex:inputTextArea id="SMSText" style="width:400px;height:80px;" value="{!SMS}"/>
        </apex:pageBlockSection>
    </apex:pageBlockSection>
    
    
    
    <apex:pageBlockButtons >
            <apex:commandButton action="{!caVaiDisto}" value="Send" />
            &nbsp; <apex:outputLink value="/home/home.jsp" id="cancelLink">Cancel</apex:outputLink>
    </apex:pageBlockButtons>
        
    
    
    </apex:pageBlock>

  </apex:form>
</apex:page>

 
sandeep sankhlasandeep sankhla
Yes, you should put this in VF page, you are getting error because the action function which you ahev used there in value you should call some class function else it will throw error, you can not assign any value to thi svalue attribute..

so you should call some class method and that method will do the rest functionality and whatever is your need...

so if you have function in class then provid ethat name..
else create one function in class and provide the name in value

class:

public void sendEmail()
{

}

<apex:actionFunction value="{!sendEmail}" immediate="true"oncomplete="setCheckboxValue();"/>

Like I mentioned these are the correct syntaxes for these..

Thanks,
Sandeep
Eelco LitjensEelco Litjens
ok, one more try, i don't seem to get it. i did a underline what i've added.
thanks already for your patience and help.. :-)
first code is class: 
public class SendSMS{

    Public string SMS{get;set;}
    Public string useThisTemplate{get;set;}
    Public List<Contact> conList {get;set;}
    Public List<Lead> leaList {get;set;}
    Public List<Deelnemer_Evenement_Training__c> DeeList {get;set;}
    Public void setCheckboxValue()
    {
    }

    Public List<string> idList = new List<string>();
    Public List<SMS_Templates__c> templates = new List<SMS_Templates__c>([SELECT Name, SMS_Text__c FROM SMS_Templates__c WHERE Inactive__c = FALSE]);
    Public Map<string, string> templateMap = new Map<string, string>();

    Public List<string> telList = new List<string>();

    public PageReference iniciaMisto(){
    
        //busca defaults ORG / USER:
        SMSMessageBirdKey__c mbkey = SMSMessageBirdKey__c.getInstance();
        string defaultCCorg = mbkey.Default_Country_Code__c;
        
        string userId = UserInfo.getUserId();
        User u = [SELECT Default_Country_Code_for_SMS__c FROM User WHERE id =: userId];
    
        //constroi a lista dos ids
        string idsString = ApexPages.currentPage().getParameters().get('recordIds');
        if(idsString != null){
            idList = idsString.split(',');

        
            //constroi a lista de Contactos / Leads:
            try{
                conList = [SELECT id, Name, MobilePhone, Alert_SMS_sent__c FROM Contact WHERE id IN: idList LIMIT 4000];
                
                for(Contact c: conList){
                    if(c.MobilePhone != null && c.MobilePhone != ''){
                        string numAux = c.MobilePhone.trim();

                        system.debug('\n\n### --- numAux: '+numAux);
                       
                       //ADD COUNTRY CODE (IF NEEDED):
                       IF( numAux.indexOf('+') == -1 ){
                       
                           //limpa caracteres especiais e leading zeros:
                            try{ numAux = numAux.trim().replaceAll('[^0-9]',''); }catch(exception ex2){}
                            integer numInt = integer.valueOf(numAux);
                            numAux = string.valueOf(numInt); 
                       
                           if(u.Default_Country_Code_for_SMS__c != '' && u.Default_Country_Code_for_SMS__c != null){
                               numAux = u.Default_Country_Code_for_SMS__c + numAux;
                           }else{
                               numAux = defaultCCorg + numAux;
                           }
                       }
                        
                        try{ numAux = numAux.replaceAll('[^0-9]',''); }catch(exception ex3){}
                        
                        system.debug('\n\n### --- numAux final: '+numAux);
                        
                        telList.add(numAux);
                    }
                }
                
                
                
            }catch(exception ex){}
            
            if(conList.size() > 0){
                string numbC = string.valueOf(conList.size());
                ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.info, numbC + ' Contacts selected (max: 4000)');
                ApexPages.addMessage(msg);
            }
            
                try{
                    leaList = [SELECT id, Name, MobilePhone FROM Lead WHERE id IN: idList LIMIT 4000];
                
                    for(Lead c: leaList){
                        if(c.MobilePhone != null && c.MobilePhone != ''){
                            string numAux = c.MobilePhone.trim();
                            
                           system.debug('\n\n### --- numAux: '+numAux);
                       
                           //ADD COUNTRY CODE (IF NEEDED):
                           IF( numAux.indexOf('+') == -1 ){
                           
                               //limpa caracteres especiais e leading zeros:
                                try{ numAux = numAux.trim().replaceAll('[^0-9]',''); }catch(exception ex2){}
                                integer numInt = integer.valueOf(numAux);
                                numAux = string.valueOf(numInt); 
                           
                               if(u.Default_Country_Code_for_SMS__c != '' && u.Default_Country_Code_for_SMS__c != null){
                                   numAux = u.Default_Country_Code_for_SMS__c + numAux;
                               }else{
                                   numAux = defaultCCorg + numAux;
                               }
                           }
                            
                            try{ numAux = numAux.replaceAll('[^0-9]',''); }catch(exception ex3){}
                            
                            system.debug('\n\n### --- numAux final: '+numAux);
                            
                            telList.add(numAux);
                        }
                    }
                
                    
                }catch(exception ex2){}
                
                try{
                    DeeList = [SELECT id, Name, Mobile_phone__c, Deelnemer__c FROM Deelnemer_Evenement_Training__c WHERE id IN: idList LIMIT 4000];
                
                    for(Deelnemer_Evenement_Training__c c: DeeList){
                        if(c.Mobile_phone__c != null && c.Mobile_phone__c != ''){
                            string numAux = c.Mobile_phone__c.trim();
                            
                           system.debug('\n\n### --- numAux: '+numAux);
                       
                           //ADD COUNTRY CODE (IF NEEDED):
                           IF( numAux.indexOf('+') == -1 ){
                           
                               //limpa caracteres especiais e leading zeros:
                                try{ numAux = numAux.trim().replaceAll('[^0-9]',''); }catch(exception ex2){}
                                integer numInt = integer.valueOf(numAux);
                                numAux = string.valueOf(numInt); 
                           
                               if(u.Default_Country_Code_for_SMS__c != '' && u.Default_Country_Code_for_SMS__c != null){
                                   numAux = u.Default_Country_Code_for_SMS__c + numAux;
                               }else{
                                   numAux = defaultCCorg + numAux;
                               }
                           }
                            
                            try{ numAux = numAux.replaceAll('[^0-9]',''); }catch(exception ex3){}
                            
                            system.debug('\n\n### --- numAux final: '+numAux);
                            
                            telList.add(numAux);
                        }
                    }
                
                    
                }catch(exception ex2){}
                
                if(leaList.size() > 0){
                    string numbL = string.valueOf(leaList.size());
                    ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.info, numbL + ' Leads selected (max: 4000)');
                    ApexPages.addMessage(msg);
                }
                                
                if(leaList.size() == 0 && conList.size() == 0 && DeeList.size() == 0){
                    ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'No Contacts or Leads selected...');
                    ApexPages.addMessage(msg);
                }

        
        }else{
            ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'No Contacts or Leads selected...');
            ApexPages.addMessage(msg);
        }
    
    return null;
    }

    public PageReference caVaiDisto(){

        system.debug('\n\n### --- SMS TO SEND: '+SMS);
        system.debug('\n\n### --- NUMBERS TO SEND: '+telList);
        
        id userId = UserInfo.getUserId();
        
        if(SMS == null || SMS == '' || telList.size() == 0){
            if(telList.size() == 0){
                ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'You must have at least one Contact to send the SMS...');
                ApexPages.addMessage(msg);
            }else{
                ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'You must specify the SMS text...');
                ApexPages.addMessage(msg);
            }
        }else{
        
            //ENVIA A CENA:
            string resultadoDaCena = SendSMSMessageBird.enviaMisto(telList, SMS);
            
            //...E GRAVA TASKS:
            List<Task> tList = new List<Task>();
            if(conList != null && conList.size() > 0){
                for(Contact c: conList){
                    Task tWa = new Task();
                    tWa.WhoId = c.Id;
                    tWa.OwnerId = userId;
                    tWa.Status='Completed';
                    string subject = '';
                    subject = 'SMS sent: '+SMS;
                    tWa.Subject = subject.abbreviate(254);
                    tWa.Description = 'SMS sent to number: '+c.MobilePhone+'\n'+'SMS text: '+SMS;
                    tWa.Type = 'SMS';
                    tList.add(tWa);
                }
            }
            
            if(DeeList != null && DeeList.size() > 0){
                for(Deelnemer_Evenement_Training__c c: DeeList){
                    Task tWa = new Task();
                    tWa.Whatid = c.Id;
                    tWa.Whoid= c.Deelnemer__c;
                    tWa.OwnerId = userId;
                    tWa.Status='Completed';
                    string subject = '';
                    subject = 'SMS sent: '+SMS;
                    tWa.Subject = subject.abbreviate(254);
                    tWa.Description = 'SMS sent to number: '+c.Mobile_phone__c+'\n'+'SMS text: '+SMS;
                    tWa.Type = 'SMS';
                    tList.add(tWa);
                }
            }
            
            if(leaList != null && leaList.size() > 0){
                for(Lead c: leaList){
                    Task tWa = new Task();
                    tWa.WhoId = c.Id;
                    tWa.OwnerId = userId;
                    tWa.Status='Completed';
                    string subject = '';
                    subject = 'SMS sent: '+SMS;
                    tWa.Subject = subject.abbreviate(254);
                    tWa.Description = 'SMS sent to number: '+c.MobilePhone+'\n'+'SMS text: '+SMS;
                    tWa.Type = 'SMS';
                    tList.add(tWa);
                }
            }
            
            if(tList.size() > 0){
                insert tList;
            }
        
            //...E INFORMA QUE TUDO CORREU BEM...
            ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.info, tList.size() + ' SMS sent');
            ApexPages.addMessage(msg);
            
            //...E MOSTRA O RETURN MESSAGE (NOT!):
            /**
            ApexPages.Message msg2 = new ApexPages.Message(ApexPages.severity.info, resultadoDaCena);
            ApexPages.addMessage(msg2);
            */
        }
        
        
    return null;
    }


    public void changeTemplateText(){
        system.debug('\n\n### --- templateMap: '+templateMap);
        system.debug('\n\n### --- useThisTemplate: '+useThisTemplate);
        SMS = templateMap.get(useThisTemplate);
        system.debug('\n\n### --- SMS CHANGE TEMPLATE TEXT: '+SMS);
    
    }
    

    public List<SelectOption> getTemplateSelectOptions() {
    
        List<SelectOption> options = new List<SelectOption>();  
        options.add(new SelectOption('','--none--'));
        for(SMS_Templates__c t: templates){
            options.add(new SelectOption(t.Name,t.Name));
            //aproveita para construír o mapa:
            templateMap.put(t.Name, t.SMS_Text__c);
        }
        return options;
        
    }

}

second code is VF page:
<apex:page tabStyle="Contact" controller="SendSMS" action="{!iniciaMisto}">
  <apex:form >
  
    <apex:sectionHeader title="Mass" subtitle="Send SMS" />
    <apex:pageMessages escape="false"/>
    <br/>
  
    <apex:pageBlock >
    <apex:pageBlockSection title="Contact List" columns="1" collapsible="false">
        <apex:pageBlockTable value="{!conList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.MobilePhone}"/>
            <apex:actionFunction value="{!setCheckboxValue}" immediate="true"  oncomplete="setCheckboxValue();"/>

define once function in javascript

<script>

function setCheckboxValue()
{
      document.getElementById('item.Alert_SMS_sent__c').Selected = true;

}
</script>

        </apex:pageBlockTable>
        <apex:pageBlockTable value="{!leaList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.MobilePhone}"/>
        </apex:pageBlockTable>
        <apex:pageBlockTable value="{!DeeList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.Mobile_phone__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlockSection>
    
    
    <apex:pageBlockSection title="Select SMS Template" columns="1" collapsible="false">
        <apex:selectList value="{!useThisTemplate}" size="1" title="Choose a template" >
            <apex:actionSupport event="onchange" rerender="textSection" action="{!changeTemplateText}" />
            <apex:selectOptions value="{!TemplateSelectOptions}"/>
        </apex:selectList>
        
        <apex:pageBlockSection id="textSection" columns="1" collapsible="false" title="SMS Text">   
            <apex:inputTextArea id="SMSText" style="width:400px;height:80px;" value="{!SMS}"/>
        </apex:pageBlockSection>
    </apex:pageBlockSection>
    
    
    
    <apex:pageBlockButtons >
            <apex:commandButton action="{!caVaiDisto}" value="Send" />
            &nbsp; <apex:outputLink value="/home/home.jsp" id="cancelLink">Cancel</apex:outputLink>
    </apex:pageBlockButtons>
        
    
    
    </apex:pageBlock>

  </apex:form>
</apex:page>

 
sandeep sankhlasandeep sankhla
you just replace action with value in action function

it should be action instead of value

thanks
sandeep sankhlasandeep sankhla
Replace your actionfunction code with below code
<apex:actionFunction action="{!setCheckboxValue}" immediate="true"oncomplete="setCheckboxValue(); rerender="textSection"

I am not able to find your checkbo which you wany to auto select ? can you please share the code of checkbox
sandeep sankhlasandeep sankhla
Because whatever Id you ahev given to checkbox that youy shoudl get in documnet.getElelemtById.. and that only you should rerender to refresh
Eelco LitjensEelco Litjens
the field name of the checkbox = Alert_SMS_sent__c
so in the code, i used item.Alert_SMS_sent__c
sandeep sankhlasandeep sankhla
But in your vf page where is the chekbox ?
Eelco LitjensEelco Litjens
I don't understand what you mean? do i have to put in something like : <apex:inputCheckbox value="item.Alert_SMS_sent__c"/>?
Eelco LitjensEelco Litjens
There's my limitation, i don't know what kind of code/command i have to use. i'm still in the copycat mode..... copy and change some code..... :-)
sandeep sankhlasandeep sankhla
yes, my question was where youhaev defined the checkbox inside VF page which you want to autopoulate as checked....you ahev simply assign chcekbox value to actionfunction which is incorrect...

where is your checkbox in vf page ?

you ahev not defined the checkbox...so
Eelco LitjensEelco Litjens
ok, i have this now: 
<apex:pageBlock >
    <apex:pageBlockSection title="Contact List" columns="1" collapsible="false">
        <apex:pageBlockTable value="{!conList}" var="item">
            <apex:column value="{!item.Alert_SMS_sent__c}"/>
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.MobilePhone}"/>
            <apex:actionFunction action="{!setCheckboxValue}" immediate="true"oncomplete="setCheckboxValue();rerender="{!item.Alert_SMS_sent__c}"/> 
            

define once function in javascript

<script>

function setCheckboxValue()
{
      document.getElementById('item.Alert_SMS_sent__c').Selected = true;

}
</script>

But still getting an error: [Error] Error: SendSMS line 14, column 79: Element type "apex:actionFunction" must be followed by either attribute specifications, ">" or "/>"
[Error] Error: Element type "apex:actionFunction" must be followed by either attribute specifications, ">" or "/>".
sandeep sankhlasandeep sankhla
<apex:actionFunction action="{!setCheckboxValue}"immediate="true"oncomplete="setCheckboxValue();" rerender="{!item.Alert_SMS_sent__c}"/>

Replace actionfunction with this

Thanks
Eelco LitjensEelco Litjens
sorry, still the same error(s)
sandeep sankhlasandeep sankhla
share the error
sandeep sankhlasandeep sankhla
Paste your entire code here so I can look into
Eelco LitjensEelco Litjens
I already did that ealier.
the error is: 
Error: SendSMS line 14, column 62: Element type "apex:actionfunction" must be followed by either attribute specifications, ">" or "/>"
[Error] Error: Element type "apex:actionfunction" must be followed by either attribute specifications, ">" or "/>".

Class code: 
public class SendSMS{

    Public string SMS{get;set;}
    Public string useThisTemplate{get;set;}
    Public List<Contact> conList {get;set;}
    Public List<Lead> leaList {get;set;}
    Public List<Deelnemer_Evenement_Training__c> DeeList {get;set;}
    Public void setCheckboxValue()
    {
    }

    Public List<string> idList = new List<string>();
    Public List<SMS_Templates__c> templates = new List<SMS_Templates__c>([SELECT Name, SMS_Text__c FROM SMS_Templates__c WHERE Inactive__c = FALSE]);
    Public Map<string, string> templateMap = new Map<string, string>();

    Public List<string> telList = new List<string>();

    public PageReference iniciaMisto(){
    
        //busca defaults ORG / USER:
        SMSMessageBirdKey__c mbkey = SMSMessageBirdKey__c.getInstance();
        string defaultCCorg = mbkey.Default_Country_Code__c;
        
        string userId = UserInfo.getUserId();
        User u = [SELECT Default_Country_Code_for_SMS__c FROM User WHERE id =: userId];
    
        //constroi a lista dos ids
        string idsString = ApexPages.currentPage().getParameters().get('recordIds');
        if(idsString != null){
            idList = idsString.split(',');

        
            //constroi a lista de Contactos / Leads:
            try{
                conList = [SELECT id, Name, MobilePhone, Alert_SMS_sent__c FROM Contact WHERE id IN: idList LIMIT 4000];
                
                for(Contact c: conList){
                    if(c.MobilePhone != null && c.MobilePhone != ''){
                        string numAux = c.MobilePhone.trim();

                        system.debug('\n\n### --- numAux: '+numAux);
                       
                       //ADD COUNTRY CODE (IF NEEDED):
                       IF( numAux.indexOf('+') == -1 ){
                       
                           //limpa caracteres especiais e leading zeros:
                            try{ numAux = numAux.trim().replaceAll('[^0-9]',''); }catch(exception ex2){}
                            integer numInt = integer.valueOf(numAux);
                            numAux = string.valueOf(numInt); 
                       
                           if(u.Default_Country_Code_for_SMS__c != '' && u.Default_Country_Code_for_SMS__c != null){
                               numAux = u.Default_Country_Code_for_SMS__c + numAux;
                           }else{
                               numAux = defaultCCorg + numAux;
                           }
                       }
                        
                        try{ numAux = numAux.replaceAll('[^0-9]',''); }catch(exception ex3){}
                        
                        system.debug('\n\n### --- numAux final: '+numAux);
                        
                        telList.add(numAux);
                    }
                }
                
                
                
            }catch(exception ex){}
            
            if(conList.size() > 0){
                string numbC = string.valueOf(conList.size());
                ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.info, numbC + ' Contacts selected (max: 4000)');
                ApexPages.addMessage(msg);
            }
            
                try{
                    leaList = [SELECT id, Name, MobilePhone FROM Lead WHERE id IN: idList LIMIT 4000];
                
                    for(Lead c: leaList){
                        if(c.MobilePhone != null && c.MobilePhone != ''){
                            string numAux = c.MobilePhone.trim();
                            
                           system.debug('\n\n### --- numAux: '+numAux);
                       
                           //ADD COUNTRY CODE (IF NEEDED):
                           IF( numAux.indexOf('+') == -1 ){
                           
                               //limpa caracteres especiais e leading zeros:
                                try{ numAux = numAux.trim().replaceAll('[^0-9]',''); }catch(exception ex2){}
                                integer numInt = integer.valueOf(numAux);
                                numAux = string.valueOf(numInt); 
                           
                               if(u.Default_Country_Code_for_SMS__c != '' && u.Default_Country_Code_for_SMS__c != null){
                                   numAux = u.Default_Country_Code_for_SMS__c + numAux;
                               }else{
                                   numAux = defaultCCorg + numAux;
                               }
                           }
                            
                            try{ numAux = numAux.replaceAll('[^0-9]',''); }catch(exception ex3){}
                            
                            system.debug('\n\n### --- numAux final: '+numAux);
                            
                            telList.add(numAux);
                        }
                    }
                
                    
                }catch(exception ex2){}
                
                try{
                    DeeList = [SELECT id, Name, Mobile_phone__c, Deelnemer__c FROM Deelnemer_Evenement_Training__c WHERE id IN: idList LIMIT 4000];
                
                    for(Deelnemer_Evenement_Training__c c: DeeList){
                        if(c.Mobile_phone__c != null && c.Mobile_phone__c != ''){
                            string numAux = c.Mobile_phone__c.trim();
                            
                           system.debug('\n\n### --- numAux: '+numAux);
                       
                           //ADD COUNTRY CODE (IF NEEDED):
                           IF( numAux.indexOf('+') == -1 ){
                           
                               //limpa caracteres especiais e leading zeros:
                                try{ numAux = numAux.trim().replaceAll('[^0-9]',''); }catch(exception ex2){}
                                integer numInt = integer.valueOf(numAux);
                                numAux = string.valueOf(numInt); 
                           
                               if(u.Default_Country_Code_for_SMS__c != '' && u.Default_Country_Code_for_SMS__c != null){
                                   numAux = u.Default_Country_Code_for_SMS__c + numAux;
                               }else{
                                   numAux = defaultCCorg + numAux;
                               }
                           }
                            
                            try{ numAux = numAux.replaceAll('[^0-9]',''); }catch(exception ex3){}
                            
                            system.debug('\n\n### --- numAux final: '+numAux);
                            
                            telList.add(numAux);
                        }
                    }
                
                    
                }catch(exception ex2){}
                
                if(leaList.size() > 0){
                    string numbL = string.valueOf(leaList.size());
                    ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.info, numbL + ' Leads selected (max: 4000)');
                    ApexPages.addMessage(msg);
                }
                                
                if(leaList.size() == 0 && conList.size() == 0 && DeeList.size() == 0){
                    ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'No Contacts or Leads selected...');
                    ApexPages.addMessage(msg);
                }

        
        }else{
            ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'No Contacts or Leads selected...');
            ApexPages.addMessage(msg);
        }
    
    return null;
    }

    public PageReference caVaiDisto(){

        system.debug('\n\n### --- SMS TO SEND: '+SMS);
        system.debug('\n\n### --- NUMBERS TO SEND: '+telList);
        
        id userId = UserInfo.getUserId();
        
        if(SMS == null || SMS == '' || telList.size() == 0){
            if(telList.size() == 0){
                ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'You must have at least one Contact to send the SMS...');
                ApexPages.addMessage(msg);
            }else{
                ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.error, 'You must specify the SMS text...');
                ApexPages.addMessage(msg);
            }
        }else{
        
            //ENVIA A CENA:
            string resultadoDaCena = SendSMSMessageBird.enviaMisto(telList, SMS);
            
            //...E GRAVA TASKS:
            List<Task> tList = new List<Task>();
            if(conList != null && conList.size() > 0){
                for(Contact c: conList){
                    Task tWa = new Task();
                    tWa.WhoId = c.Id;
                    tWa.OwnerId = userId;
                    tWa.Status='Completed';
                    string subject = '';
                    subject = 'SMS sent: '+SMS;
                    tWa.Subject = subject.abbreviate(254);
                    tWa.Description = 'SMS sent to number: '+c.MobilePhone+'\n'+'SMS text: '+SMS;
                    tWa.Type = 'SMS';
                    tList.add(tWa);
                }
            }
            
            if(DeeList != null && DeeList.size() > 0){
                for(Deelnemer_Evenement_Training__c c: DeeList){
                    Task tWa = new Task();
                    tWa.Whatid = c.Id;
                    tWa.Whoid= c.Deelnemer__c;
                    tWa.OwnerId = userId;
                    tWa.Status='Completed';
                    string subject = '';
                    subject = 'SMS sent: '+SMS;
                    tWa.Subject = subject.abbreviate(254);
                    tWa.Description = 'SMS sent to number: '+c.Mobile_phone__c+'\n'+'SMS text: '+SMS;
                    tWa.Type = 'SMS';
                    tList.add(tWa);
                }
            }
            
            if(leaList != null && leaList.size() > 0){
                for(Lead c: leaList){
                    Task tWa = new Task();
                    tWa.WhoId = c.Id;
                    tWa.OwnerId = userId;
                    tWa.Status='Completed';
                    string subject = '';
                    subject = 'SMS sent: '+SMS;
                    tWa.Subject = subject.abbreviate(254);
                    tWa.Description = 'SMS sent to number: '+c.MobilePhone+'\n'+'SMS text: '+SMS;
                    tWa.Type = 'SMS';
                    tList.add(tWa);
                }
            }
            
            if(tList.size() > 0){
                insert tList;
            }
        
            //...E INFORMA QUE TUDO CORREU BEM...
            ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.info, tList.size() + ' SMS sent');
            ApexPages.addMessage(msg);
            
            //...E MOSTRA O RETURN MESSAGE (NOT!):
            /**
            ApexPages.Message msg2 = new ApexPages.Message(ApexPages.severity.info, resultadoDaCena);
            ApexPages.addMessage(msg2);
            */
        }
        
        
    return null;
    }


    public void changeTemplateText(){
        system.debug('\n\n### --- templateMap: '+templateMap);
        system.debug('\n\n### --- useThisTemplate: '+useThisTemplate);
        SMS = templateMap.get(useThisTemplate);
        system.debug('\n\n### --- SMS CHANGE TEMPLATE TEXT: '+SMS);
    
    }
    

    public List<SelectOption> getTemplateSelectOptions() {
    
        List<SelectOption> options = new List<SelectOption>();  
        options.add(new SelectOption('','--none--'));
        for(SMS_Templates__c t: templates){
            options.add(new SelectOption(t.Name,t.Name));
            //aproveita para construír o mapa:
            templateMap.put(t.Name, t.SMS_Text__c);
        }
        return options;
        
    }

}

VF code: 
<apex:page tabStyle="Contact" controller="SendSMS" action="{!iniciaMisto}">
  <apex:form >
  
    <apex:sectionHeader title="Mass" subtitle="Send SMS" />
    <apex:pageMessages escape="false"/>
    <br/>
  
    <apex:pageBlock >
    <apex:pageBlockSection title="Contact List" columns="1" collapsible="false">
        <apex:pageBlockTable value="{!conList}" var="item">
            <apex:column value="{!item.Alert_SMS_sent__c}"/>
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.MobilePhone}"/>
            <apex:actionFunction action="{!setCheckboxValue}"immediate="true"oncomplete="setCheckboxValue();" rerender="{!item.Alert_SMS_sent__c}"/>
           

define once function in javascript

<script>

function setCheckboxValue()
{
      document.getElementById('item.Alert_SMS_sent__c').Selected = true;

}
</script>

        </apex:pageBlockTable>
        <apex:pageBlockTable value="{!leaList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.MobilePhone}"/>
        </apex:pageBlockTable>
        <apex:pageBlockTable value="{!DeeList}" var="item">
            <apex:column value="{!item.Name}"/>
            <apex:column value="{!item.Mobile_phone__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlockSection>
    
    
    <apex:pageBlockSection title="Select SMS Template" columns="1" collapsible="false">
        <apex:selectList value="{!useThisTemplate}" size="1" title="Choose a template" >
            <apex:actionSupport event="onchange" rerender="textSection" action="{!changeTemplateText}" />
            <apex:selectOptions value="{!TemplateSelectOptions}"/>
        </apex:selectList>
        
        <apex:pageBlockSection id="textSection" columns="1" collapsible="false" title="SMS Text">   
            <apex:inputTextArea id="SMSText" style="width:400px;height:80px;" value="{!SMS}"/>
        </apex:pageBlockSection>
    </apex:pageBlockSection>
    
    
    
    <apex:pageBlockButtons >
            <apex:commandButton action="{!caVaiDisto}" value="Send" />
            &nbsp; <apex:outputLink value="/home/home.jsp" id="cancelLink">Cancel</apex:outputLink>
    </apex:pageBlockButtons>
        
    
    
    </apex:pageBlock>

  </apex:form>
</apex:page>

sorry for the "noob" level :-)
sandeep sankhlasandeep sankhla
<apex:actionFunction action="{!setCheckboxValue}"immediate="true"oncomplete="setCheckboxValue();" rerender="{!item.Alert_SMS_sent__c}"/>

here is teh mistake, in rerender only elemsnt Id we should pass like textSection which is pageblock id....value we should not pass there....
Eelco LitjensEelco Litjens
hmm, ok, this is already a little above my understanding.....  is it possible for you to check and change any? would be greatly appreciated