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
kasa venkat 14kasa venkat 14 

picklist value is a header of the page

Hi i have a requirment, i have a multipicklist field with values(India,chaina,usa) if i select any one of this values i want to be header of the page.
for example if i select INDIA  and click on save button.it add as a Header of the page.is it possible to do??
thanks for advace

<apex:page controller="customPickListInVFDemoController" tabStyle="Account" > 
  <apex:form >
    <apex:pageBlock id="out">
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" rerender="out" status="actStatusId"/>
            <apex:actionStatus id="actStatusId">
                <apex:facet name="start">
                    <img src="/img/loading.gif" />
                </apex:facet>
            </apex:actionStatus>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Target Audiance" collapsible="false">
            <apex:selectList value="{!selectedCountry1}" multiselect="True" size="1">
                
                <apex:selectOption itemValue="India" itemLabel="India"/>
                <apex:selectOption itemValue="usa" itemLabel="usa"/>
            </apex:selectList>
            <apex:outputText value="{!selectedCountry1}" label="You have selected:"/>
        </apex:pageBlockSection>
     </apex:pageblock>
  </apex:form>
</apex:page>

public class customPickListInVFDemoController {
public String selectedCountry1{get;set;}
public String selectedCountry2{get;set;}
    public customPickListInVFDemoController(){
    }
     
    public List<SelectOption> getCountriesOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        
        countryOptions.add(new SelectOption('india','india'));
        countryOptions.add(new SelectOption('usa','usa'));
        return countryOptions;
    }
    public PageReference save(){
        return null;
    }
}
Best Answer chosen by kasa venkat 14
Harish RamachandruniHarish Ramachandruni
Hi,

replace this code in your account 
 
<apex:page controller="customPickListInVFDemoController" tabStyle="Account" sidebar="false" > 
  <apex:form id="out" >
<apex:sectionHeader title="harish" subtitle="{!country}" />

    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" rerender="out" status="actStatusId"/>
            <apex:actionStatus id="actStatusId">
                <apex:facet name="start">
                    <img src="/img/loading.gif" />
                </apex:facet>
            </apex:actionStatus>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Target Audiance" collapsible="false">
        
        <apex:selectList value="{!country}" size="1" >
        
    <apex:selectOptions value="{!CountriesOptions}"></apex:selectOptions>
        
        
        </apex:selectList>
        
           
        </apex:pageBlockSection>
     </apex:pageblock>
  </apex:form>
</apex:page>
 
public class customPickListInVFDemoController {

   

    public String country { get; set; }


    public customPickListInVFDemoController(){
    
    }
     
    public List<SelectOption> getCountriesOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        
        countryOptions.add(new SelectOption('india','india'));
        countryOptions.add(new SelectOption('usa','usa'));
        return countryOptions;
    }
    public PageReference save(){
    
        return null;
    }
}



If any issue ask me .


Regards ,
harish.R

All Answers

Harish RamachandruniHarish Ramachandruni
Hi,

replace this code in your account 
 
<apex:page controller="customPickListInVFDemoController" tabStyle="Account" sidebar="false" > 
  <apex:form id="out" >
<apex:sectionHeader title="harish" subtitle="{!country}" />

    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" rerender="out" status="actStatusId"/>
            <apex:actionStatus id="actStatusId">
                <apex:facet name="start">
                    <img src="/img/loading.gif" />
                </apex:facet>
            </apex:actionStatus>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Target Audiance" collapsible="false">
        
        <apex:selectList value="{!country}" size="1" >
        
    <apex:selectOptions value="{!CountriesOptions}"></apex:selectOptions>
        
        
        </apex:selectList>
        
           
        </apex:pageBlockSection>
     </apex:pageblock>
  </apex:form>
</apex:page>
 
public class customPickListInVFDemoController {

   

    public String country { get; set; }


    public customPickListInVFDemoController(){
    
    }
     
    public List<SelectOption> getCountriesOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        
        countryOptions.add(new SelectOption('india','india'));
        countryOptions.add(new SelectOption('usa','usa'));
        return countryOptions;
    }
    public PageReference save(){
    
        return null;
    }
}



If any issue ask me .


Regards ,
harish.R
This was selected as the best answer
Harish RamachandruniHarish Ramachandruni
Hi, 

is it working .


Regards ,
Harish.R.
kasa venkat 14kasa venkat 14
Hi Hareesh,
it works but my field is multipicklist.
 
kasa venkat 14kasa venkat 14
im unable to select morethan one country
 
Harish RamachandruniHarish Ramachandruni
Hi,

Change Code  hedder value as selectedCountry1 in sectionhedder .


Regards ,
Harish.R
Harish RamachandruniHarish Ramachandruni
Hi,


Upadte This Vf page In your Org 

 
<apex:page controller="customPickListInVFDemoController" tabStyle="Account" sidebar="false" > 
  <apex:form id="out" >
<apex:sectionHeader title="harish" subtitle="{!country}" />

    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" rerender="out" status="actStatusId"/>
            <apex:actionStatus id="actStatusId">
                <apex:facet name="start">
                    <img src="/img/loading.gif" />
                </apex:facet>
            </apex:actionStatus>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Target Audiance" collapsible="false">
        
        <apex:selectList value="{!country}"  multiselect="true" style="width:100px" size="5" >
        
    <apex:selectOptions value="{!CountriesOptions}"></apex:selectOptions>
        
        
        </apex:selectList>
        
           
        </apex:pageBlockSection>
     </apex:pageblock>
  </apex:form>
</apex:page>


If u have any issue ask me imediatly .  If it is usefull make it as solved .


Regards ,
Harish.R
kasa venkat 14kasa venkat 14
Hi Hareesh,
im unable to select morethan one country

<apex:sectionHeader title="selectedCountry1" subtitle="{!country}" />
    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" rerender="out" status="actStatusId"/>
            <apex:actionStatus id="actStatusId">
                <apex:facet name="start">
                    <img src="/img/loading.gif" />
                </apex:facet>
            </apex:actionStatus>

so this is the functionality you r using for selected value as a Header right.
 
Harish RamachandruniHarish Ramachandruni
Hi,


Please use below code . 
 
<apex:page controller="customPickListInVFDemoController" tabStyle="Account" sidebar="false" > 
  <apex:form id="out" >
<apex:sectionHeader title="harish" subtitle="{!country}" />

    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" rerender="out" status="actStatusId"/>
            <apex:actionStatus id="actStatusId">
                <apex:facet name="start">
                    <img src="/img/loading.gif" />
                </apex:facet>
            </apex:actionStatus>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Target Audiance" collapsible="false">
        
        <apex:selectList value="{!country}"  multiselect="true" style="width:100px" size="5" >
        
    <apex:selectOptions value="{!CountriesOptions}"></apex:selectOptions>
        
        
        </apex:selectList>
        
           
        </apex:pageBlockSection>
     </apex:pageblock>
  </apex:form>
</apex:page>



Regards ,
Harish.R.
kasa venkat 14kasa venkat 14
Thanks Harish,
thats fine.
 
Harish RamachandruniHarish Ramachandruni
Hi,


Any Issue or errors ask me harish.rao.salesforce@gmail.com .



Regards ,
Harish.R