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
NickHockingNickHocking 

Misunderstanding Param?

Hi All,

 

I am VERY new to VF...

 

I have a field (x), which is a picklist that has 3 options (A, B, C).

 

I want to right an application which can be in it's own tab.

 

This application is SIMPLY so the user can select A, B, or C from the picklist and the page will then display one of three values.... if A, show 50, if B, show 100, if C, show 150. 

 

The text that shows (50 or 100 or 150) should be text.

 

I've been trying to have the picklist (x) as an inputField, then, within the inputfield, using a <apex:param> to assign a variable which i can then reference in an outputField, but i am obviously doing this all wrong.

 

Please can someone point in the direction of how to do this in simple terms??

 

I really appreciate your help, thanks

Shailesh DeshpandeShailesh Deshpande
You dont need to do that. When you use inputfield, your picklist value is automatically bounded to the variable that you use in the class. So, you can simply write a actionfunction or an action support for onChange event and rerender the page based on the value selected.
NickHockingNickHocking
Hi Shailesh.

Thanks for the reply, but I'm quite confused as to how to actually do that.....if you have a few mins to show some example code I'd really appreciate - I'm a bit lost...
Shailesh DeshpandeShailesh Deshpande
I havent tested this but Something similar should work for you:

<apex:pageBlock id="pb">

<apex:inputfield value="{!obj.myPicklistVal}" onChange="doThis();"/>

<apexOutPutText value="{!myTextValue}"/>

</apexPageblock>

<apex:actionFunction name="doThis" action="{!controllerDoThis}" rerender="pb">

In Controller:

Public String MyTextValue {get;set}
Public myobject obj{get; set;}

Public void controllerDoThis()
{
If(obj.myPicklistVal = 'something'){
myTextValue = 'A';
}
Else If(obj.myPicklistVal = 'some other thing'){
myTextValue = 'B';
}
}

NOTE: INITIALIZE the values in controller constructor.
NickHockingNickHocking
Thanks but really cant get that to work. Sorry.
Shailesh DeshpandeShailesh Deshpande
Can you post your code?