+ Start a Discussion
Prema -Prema - 

Why onclick doesnt work in my vf page for Select options

<apex:page controller="CheckEmailwithContact" >
  
  <apex:form >
  <apex:pageBlock title="Select Options as per your choice" >
<apex:selectRadio value="{!selectedCheckbox}" onclick="!getCons2(this.value)"  immediate="true">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio><p/>
<!--<apex:commandButton value="Click Here" action="{!getCons2}"/>-->
</apex:pageBlock>
</apex:form>
 <apex:pageblock >
          <apex:pageBlockTable value="{!conlists}" var="l" id="Table">
          <apex:column headerValue="First Name" value="{!l.FirstName}"/>
          <apex:column headerValue="Last Name" value="{!l.LastName}"/>     
          <apex:column headerValue="Email" value="{!l.Email}"/>  
          </apex:pageBlockTable>
          
  </apex:pageBlock>
 
</apex:page>

 
Rambo SusonRambo Suson
onclick="getCont2(this.value)"  maybe we dont need "!"
Prema -Prema -
No it still doesnt work,
Sampath SuranjiSampath Suranji
Hi,
I guess you are going to call an apex method in onClick, If so try something like below.
<apex:page controller="CheckEmailwithContact" >
    
    <apex:form >
        <apex:pageBlock title="Select Options as per your choice" >
            <apex:selectRadio value="{!selectedCheckbox}" onclick="callApexMethod()"  immediate="true">
                <apex:selectOptions value="{!items}"/>
            </apex:selectRadio><p/>
            
        </apex:pageBlock>
        <apex:actionFunction action="{!getCons2}" name="callApexMethod">
           
        </apex:actionFunction>
    </apex:form>
    <apex:pageblock >
        <apex:pageBlockTable value="{!conlists}" var="l" id="Table">
            <apex:column headerValue="First Name" value="{!l.FirstName}"/>
            <apex:column headerValue="Last Name" value="{!l.LastName}"/>     
            <apex:column headerValue="Email" value="{!l.Email}"/>  
        </apex:pageBlockTable>
        
    </apex:pageBlock>
    
</apex:page>
in controller you can access the 'selectedCheckbox'  value directly
public void getCons2(){
        
        System.debug('selectedCheckbox '+selectedCheckbox);
  }

regards
Sampath

 
Deepak Kumar SharmaDeepak Kumar Sharma
Hi Prema-,
Could you please post whole code of vf page?
Thanks
Prema -Prema -
Hello Sampath, and Deepak thanks for the response but i believe we cant call a[ex method directly onclick of a button it should be i think only javascript as per the salesforce document/ But i need some help still on different thread regarding the wrapper class. could you please help me with that.