+ Start a Discussion
Kushal MishraKushal Mishra 

hello guys, please help me i am new in visual force environment , i want to create a input Field(mandatory) after selecting second option in picklist and picklist should contains only two option 'first' and 'second'.

Hi Kushal,

Please have a look into below example.

Visualforce Page:
<apex:page standardController="Account" extensions="testController">
  <apex:form >        
         <apex:pageBlock id="mainPb" title="Test" mode="Edit" >
             <apex:pageBlockSection id="pbSection">
                 <apex:pageBlockSectionItem id="sectionItemList">
                     <apex:outputText value="Select Value"></apex:outputText>
                     <apex:selectList value="{!strSelectedValue}" size="1" >
                         <apex:selectOptions value="{!listOptions}" />
                         <apex:actionSupport event="onchange" reRender="mainPb" />
                 <apex:pageBlockSectionItem id="sectionItemAccName">
                     <apex:outputText value="Name"></apex:outputText>
                     <apex:inputField value="{!Account.Name}" required="{!if(strSelectedValue == 'Second',true,false)}" />

Apex Class:
Public Class testController{
    public String strSelectedValue{get;set;}
    public List<SelectOption> listOptions{get;set;}
    public testController (ApexPages.StandardController objStandardController){
        listOptions = new List<SelectOption>();
        listOptions.Add(new SelectOption('First','First'));
        listOptions.Add(new SelectOption('Second','Second'));

User-added image

Thanks and Regards,
Kushal MishraKushal Mishra
it is ok.  but i want that when i select closed then Regsion field automatic present in this page without clicking save page.please tell me...thanks .