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
Harsh Aditya 8Harsh Aditya 8 

How to load the pageblock

Hi,
I want to divide the visualforce page into two blocks and when the user clicks the item of the list which is present in the block 1,the block 2  should refresh the page and give some description(using jQuery).only block 2 should refresh and laod the different page according to the user selection .
Himanshu ParasharHimanshu Parashar
Hi Harsh,

There are different method available inside Salesforce for what you are looking for. Following code is one of them.
 
<apex:pageblock>
<apex:selectList value="{!selectId}" size="1">
        <apex:selectOptions value="{!display}"></apex:selectOptions>
        <apex:actionSupport event="onchange" action="{!displayvalue}" reRender="resultpanel"/>
    </apex:selectList>
</apex:pageblock>

<apex:outputpanel id="resultpanel">
<apex:pageblock>{!Controllervariable}</apex:pageblock>


</apex:outputpanel>

In Above code reRender attribute will refresh pageblock 2 from server value with ajax call.

Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S.  If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Harsh Aditya 8Harsh Aditya 8
Hi Himanshu,
sorry for the late reply, plz provide the apex code as well. I am new to the Salesforce,am getting some error dividing the page and on-updating
thanks
Himanshu ParasharHimanshu Parashar
Hi Harsh,

Please find following code and try to understand this.
 
public with sharing class onchage {

    public String Controllervariable { get; set; }

    //calling this method from page to update controller side value
    public PageReference displayvalue() {
    
        Controllervariable='Selected Country is : ' + selectId;
        return null;
    }

    //These are the list items.
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('US','US'));
        options.add(new SelectOption('CANADA','Canada'));
        options.add(new SelectOption('MEXICO','Mexico'));
        return options;
    }

    public String SelectId{get;set;}

}

VF Page :
 
<apex:page controller="onchage">
 <apex:form >
<apex:pageblock >
<apex:selectList value="{!selectId}" size="1">
        <apex:selectOptions value="{!items}"/>
        <apex:actionSupport event="onchange" action="{!displayvalue}" reRender="resultpanel"/>
    </apex:selectList>
</apex:pageblock>

<apex:outputpanel id="resultpanel">
<apex:pageblock >{!Controllervariable}</apex:pageblock>


</apex:outputpanel>

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

Thanks,
Himanshu