You need to sign in to do that
Don't have an account?
zmziga
Get value from InputField
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"?
Hi,
<apex:inputField label="Label:" value="{User__c.attribute__c}">
<apex:actionSupport event="onchange" />
</apex:inputField>
<apex:outputPanel id="ot" rendered="{User__c.attribute__c!=null}">
<apex:inputField label="Label 2:" value="{!User__c.attribute2__c}"/>
</apex:outputPanel>
try this if first inputfield have value means shown on second inputfiled or otherwise hidden.
if u want to get the value from inputfield means using controller or javascript.
All Answers
Hi.
How about this?
Page
Regards,
<apex:inputField label="Label:" value="{!User__c.attribute__c}">
<apex:actionsupport event="onchange" rerender="details"/>
</apex:inputField>
<apex:outputpanel id="details">
<apex:inputField label="Label 2:" value="{!User__c.attribute2__c}" rendered="{!IF(User__c.attribute__c='something',true,false)}"/>
</apex:outputpanel>
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Unfortunately this solution does not work. It is as if this does not work:
Because if I output result for User__c.attribute__c ..it is always empty. Even if I set default value for User__c.attribute__c, it still shows as empty. That's why I asked how to get value from InputField, because this does not work.
edit: Does that change anything if first inputfield is picklist? So when I select value from picklist, it shows another field or it hides it.
Hi,
<apex:inputField label="Label:" value="{User__c.attribute__c}">
<apex:actionSupport event="onchange" />
</apex:inputField>
<apex:outputPanel id="ot" rendered="{User__c.attribute__c!=null}">
<apex:inputField label="Label 2:" value="{!User__c.attribute2__c}"/>
</apex:outputPanel>
try this if first inputfield have value means shown on second inputfiled or otherwise hidden.
if u want to get the value from inputfield means using controller or javascript.
Check like this
<apex:inputField label="Label:" value="{!User__c.attribute__c}">
<apex:actionsupport event="onchange" rerender="details"/>
</apex:inputField>
<apex:outputpanel id="details">
<apex:inputField label="Label 2:" value="{!User__c.attribute2__c}" rendered="{!User__c.attribute__c == 'something'}"/>
</apex:outputpanel>
Thank you, Kodi!
This one worked. I don't know yet why, but if I used "reRender" it didn't work. But without "rerender" it worked. Sadly it refreshes whole page and not just section. If anyone knows why this does not work, please let me know.
Thank you for all your answers!
This did not work...
I worked at this.