+ Start a Discussion
chanti kchanti k 

i want display the records on Account object,whenever select the value of pick list in visualforce page ?

Hi Bro,

This is my requirement i want display the records on Account object,whenever select the value of pick list in visualforce page  .Here i am attaching my page and class. i am  thinking Action is not working..pls help me 
PAGE:

<apex:page standardController="Account" extensions="fetchdisplayrecords">
      <apex:form >
          <apex:pageBlock id="Block" >
              <div style="width:700px; margin:0 auto;">
              
                
                      
                      <apex:outputText value="List of Contacts : "/>
                      <apex:selectList value="{!selectedItemValue}" multiselect="false" size="1">
                     <apex:actionSupport event="onchange"  action="{!changeRec}" status="thestatus" reRender="theform" />
                     <apex:selectOptions value="{!items}"/>
                 </apex:selectList>
                 </div>
                 
                  
              
          </apex:pageBlock>
          <apex:actionStatus id="thestatus" startText="Please Wait It's Loading....."></apex:actionStatus>
          <apex:detail subject="{!recId}" rendered="{!if(recId!=null,true,false)}" relatedList="false"/>
      </apex:form>
</apex:page>







Class 



Public class fetchdisplayrecords
{
public Account Acc {get; set;}
public string selectedItemValue{get;set;}
public id recId {get;set;}
public fetchdisplayrecords(ApexPages.StandardController controller)
 {
   //acc = [SELECT Name, AccountNumber FROM Account limit 5];
 }
     public List<selectoption> getitems()
     {
     List<Selectoption> opts = new List<Selectoption>();
        opts.add(new selectoption('','--None--'));
        for(Account Acc: [Select Id,Name From Account limit 10]){   
                opts.add(new selectoption(Acc.Id,Acc.Name));
        }
   return opts;
     }
     
     public pageReference changeRec()
     {
     if(selectedItemValue!=null&&selectedItemValue!='')
       {
          recId = selectedItemValue;  
        }
        else recId = null;
        return null;
     }
}



Note: Values are came into the picklist..after selecting the value i didn't recive the records..Could you pls help me..let me know where is mistake.

Thanks ,
Chanti
Santosh Reddy9989Santosh Reddy9989
Hi chanti,
you forgot declaring id : theform,

<apex:page standardController="Account" extensions="myControllerExtension" >
      <apex:form id="theform" >
          <apex:pageBlock id="Block" >
              <div style="width:700px; margin:0 auto;">
              
                
                      
                      <apex:outputText value="List of Contacts : "/>
                      <apex:selectList value="{!selectedItemValue}" multiselect="false" size="1">
                     <apex:actionSupport event="onchange"  action="{!changeRec}" status="thestatus" reRender="theform" />
                     <apex:selectOptions value="{!items}"/>
                 </apex:selectList>
                 </div>
                 
                  
              
          </apex:pageBlock>
          <apex:actionStatus id="thestatus" startText="Please Wait It's Loading....."></apex:actionStatus>
          <apex:detail subject="{!recId}" rendered="{!if(recId!=null,true,false)}" relatedList="false" />
      </apex:form>
</apex:page>