You need to sign in to do that
Don't have an account?
how to dispaly item selected in picklist in visualforce page
Hi,
This is my code,
<apex:page controller="picklistTest" showHeader="false" >
<apex:form >
<apex:pageBlock title="Sample">
<apex:pageBlock title="Select the Quarter:">
<apex:selectList value="{!selectedVal}" size="1">
<apex:selectOptions value="{!options1}"/>
</apex:selectList>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
I have some values in the picklist and once the user selects a value from the list i want to display that value (i.e) label in the same visualforce page in a seperate section.
Can anyone share some code to achieve this?
Please help me
Regards,
S.Sivakumar
You can't enclose apex:actionregion inside apex:selectlist. So try reverse.
All Answers
- So if you want the value on change of that picklist then use apex:actionsupport and rerender another section.
- if you want it on button click, then you could use command button to rerender the new another section.
Note: In your another section, you will be putting the selected value.
Hey thanks for your reply.
I changed my code as you mentioned.
but i am getting the following error
Visualforce Error
Select components should have at least one child component of type selectOption or selectOptions
Here is my code,
<apex:page controller="picklistTest" showHeader="false" >
<apex:form >
<apex:pageBlock title="Sample">
<apex:pageBlock title="Select Quarter :">
<apex:selectList value="{!selectedVal}" size="1">
<apex:actionRegion >
<apex:actionSupport event="onchange" rerender="sample1"/>
<apex:selectOptions value="{!options1}"/>
</apex:actionRegion>
</apex:selectList>
</apex:pageBlock>
<apex:PageblockSection title="sample" columns="1" id="sample1" >
<apex:OutputLabel >Selected Period</apex:OutputLabel>
{!selectedVal}
</apex:PageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
You can't enclose apex:actionregion inside apex:selectlist. So try reverse.
hey its working.
But i am getting id of the corresponding one. I want to display the label of it.
How to achieve this?
Regards,
S.Sivakumar
i dont know how to do it. can u help me with some code?
Regards,
S.Sivakumar
I have written some code, it might help you.
Let us know if you need any help.
Heys its working,
Thanks a lot
Can u please explain me the concept?
Thanks,
S.Sivakumar
Then on button click we can get the selected value from that map.
Refer my post again, I have added comments in appropriate places.
Similarly i have to use the selected item id in the picklists and have to query to get another result based on that id.
I used same selectedval for that.but i am not able to get results (i.e)label from controller to visualforce page and i am able to dispaly the id of the query result.
I stored the results of the query in List<sobject> and i want ti get the label not the index.
Thanks,
S.Sivakumar
hey thanks,
I got the logic. I used map function to achieve that.
Right now i want to calculate day in a quarter(i.e) if user selects Quarter 1 2013 from the picklists then i want to display the current day in that quarter. Suppose if he selects the passed quarter then i want to display,"quarter completed". I dont know how to achieve this.
Please help me.
Regards,
S.Sivakumar