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
Jonas MyhreJonas Myhre 

Picklist value insert text to visualforce

Hi guys, need some help. Im creating a VF page, where i want to select a field and populate the text field right next to it with text. How would i go forth and do that?

I attached a photo below to illustrate. Red, white and blue should display different text in the text area right next to it.

Capture

Thanks alot!
Ramu_SFDCRamu_SFDC
You would need to use action support something as explained in the below post

http://stackoverflow.com/questions/10015597/display-fields-based-on-selection-on-a-picklist-selection
Gaurav NirwalGaurav Nirwal
<apex:page controller="clientobject">
<apex:form >
<apex:pageBlock >
  <apex:selectList id="countries" value="{!picklist}" size="1">
  <apex:selectOptions value="{!countries}"/>
</apex:selectList><br/><br/>
  Enter value to add:<apex:inputText value="{!pick}"/>
  <apex:commandButton value="add" />
</apex:pageBlock>
</apex:form>
</apex:page>
//controller class
public class clientobject {
public string pick{set;get;}
public string picklist{set;get;}
transient List<Schema.PicklistEntry> ple = new List<Schema.PicklistEntry>();
public clientobject(){
}
public List<SelectOption> getCountries(){

  List<SelectOption> options = new List<SelectOption>();
   Schema.DescribeFieldResult fieldResult = OfficeLocation__c.Country__c.getDescribe();
  ple = fieldResult.getPicklistValues();
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }     
    system.debug('picklist values are ::::::::::'+options);
   return options;
  }
}

Gaurav NirwalGaurav Nirwal
public class dynamicpicklist
{
public String city{get; set;}

public List<SelectOption> getcitynames()
{
  List<SelectOption> options = new List<SelectOption>();
  List<DynamicPicklist__c> citylist = new List<DynamicPicklist__c>();
  citylist = [Select Id, PicklistValue__c FROM DynamicPicklist__c ];
  options.add(new SelectOption('--None--','--None--'));
  for (Integer j=0;j<citylist.size();j++)
  {
      options.add(new SelectOption(citylist[j].PicklistValue__c,citylist[j].PicklistValue__c));
  }
  return options;
}
public String newpicklistvalue{get; set;}

public void saverec()
{
  DynamicPicklist__c newrec = new DynamicPicklist__c(PicklistValue__c=newpicklistvalue);
  insert newrec;
  newpicklistvalue=NULL;
}

}