• zmziga
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

I have an input field.

<apex:inputField label="Label:" value="{!User__c.attribute__c}"/>

 

And based on the written input, I'd like to have another field shown/hidden. (I rerender second inputfield after changing first inputfield)


 <apex:inputField label="Label 2:" value="{!User__c.attribute2__c}" rendered="{!IF(User__c.attribute__c='something',true,false)}"/>

 

But I assume, that I cannot get value from first field like that.

 

My question is how to get value from inputfield, so I can use later it in "rendered"?

  • September 30, 2013
  • Like
  • 0

When I create a new user, I have option to select type of user (it can be either x or y-Picklist). And now if I select type x, inputfield called "something" will show (by default it is hidden). And if I select type y, this inputfield will hide. I hoped it would work like this, but it does not.

 

I have the following code:

 <apex:form >
          <apex:pageBlock title="Create new user" tabstyle="User__c">
               <apex:pageBlockSection columns="1">
                  <apex:inputField label="Name" value="{!User__c.name__c}"/>
                  <apex:inputField label="Type of user" value="{!User__c.type__c}">
                      <apex:actionSupport event="onchange" rerender="something"/>
                  </apex:inputField>
                  <apex:pageBlockSection id="something" rendered="{!IF(User__c.type__c='x',true,false)}">
                      <apex:inputField label="Something: " value="{!User__c.something__c}"/>
                  </apex:pageBlockSection>
               </apex:pageBlockSection>
             <apex:pageBlockButtons >
                 <apex:commandButton value="Save" action="{!save}"/>
             </apex:pageBlockButtons>
          </apex:pageBlock>
      </apex:form>

 

Can anybody help me?

  • September 29, 2013
  • Like
  • 0

I have an input field.

<apex:inputField label="Label:" value="{!User__c.attribute__c}"/>

 

And based on the written input, I'd like to have another field shown/hidden. (I rerender second inputfield after changing first inputfield)


 <apex:inputField label="Label 2:" value="{!User__c.attribute2__c}" rendered="{!IF(User__c.attribute__c='something',true,false)}"/>

 

But I assume, that I cannot get value from first field like that.

 

My question is how to get value from inputfield, so I can use later it in "rendered"?

  • September 30, 2013
  • Like
  • 0

I'm new on salesforce.

I'm trying to create dependent fields according to picklist value selection.

In the following code I want:

1: when I select "None" in picklist no field should display.

2: if I select 1st option in the picklist; only field1 should get display.

3: if I select 2nd option in the picklist; only field2 should get display.

3: and if I select 3rd option in the picklist; all the fields1,2&3 should get display.

 

Please Help me out of this task.. Thanks!

 

/////////////////////Visualforce///////////////////////

<apex:page controller="FieldSelection">
      <apex:pageBlock title="fields">
          <apex:form >
                <b>State:</b> <t/><t/>
                <apex:selectList id="sta" value="{!SelectedState}" size="1">
                    <apex:selectOptions value="{!StateList}" />
                </apex:selectList>
                <br/><br/>
                <b>Field1:</b><t/><t/>
                <apex:inputText required="true" id="city1" value="{!city1}" />
                <br/><br/>
                <b>Field2:</b><t/><t/>
                <apex:inputText required="true" id="city2" value="{!city2}" />
                <br/><br/>
                <b>Field3:</b><t/><t/>
                <apex:inputText required="true" id="city3" value="{!city3}" />
                
          </apex:form>
      </apex:pageBlock>
</apex:page>

 

 

 

/////////////////////////Controller/////////////////////////////////

public with sharing class FieldSelection {

    public String city3 { get; set; }

    public String city2 { get; set; }

    public String city1 { get; set; }

    public String SelectedState { get; set; }
    
    public list<SelectOption> StateList{
    get{
            list<SelectOption> st= new list<SelectOption>();
            st.add(new SelectOption('','- None -'));
            List<UV_Account__c> lFINAL = New List<UV_Account__c>();
            list<UV_Account__c> cc=[select State__c from UV_Account__c];
            Set<String> sNames = New Set<String>();
            for (UV_Account__c c : cc){
            if (sNames.Contains(c.State__c) == FALSE){
               sNames.add(c.State__c);
               lFINAL.add(c);
        }
        }
            
            for( UV_Account__c fc : lFINAL)
            {
                st.add(new SelectOption(fc.id,fc.State__c));
            }
            return st;
       }
     set; }

}