You need to sign in to do that
Don't have an account?

How to solve this select option
I have a visual force page, On that page I created a pick list.. I am fetching the values of account. Now when I selected
One record related..Id should display how can I do that?
The code as follows.
<apex:page controller="selectlist">
<apex:form >
<apex:selectList value="{!sv}" size="1" rendered="true" onselect="output">
<apex:selectOptions value="{!value}">
</apex:selectOptions>
</apex:selectList>
</apex:form>
<apex:outputPanel id="output">
<apex:outputLabel value="{!Iddisplay}">
</apex:outputLabel>
</apex:outputPanel>
</apex:page>
------------------------------------------------ APEX CLASS------------------------------------
public class selectlist
{
public String sv { get; set; }
public String getIddisplay()
{
return null;
}
public List<SelectOption> getValue()
{
List<SelectOption> option = new List<SelectOption>();
option.add(new selectoption('none','---Select--'));
for(Account ac: [Select Id,name From Account limit 5])
{
option.add(new SelectOption(ac.id,ac.name));
}
return option;
}
}
Hi vamshi,
You have to use actionFunction tag using javascript to call controller method to display selected recordId.
see below example.
visualforce Page:
Apex Class:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
All Answers
Hi vamshi,
You have to use actionFunction tag using javascript to call controller method to display selected recordId.
see below example.
visualforce Page:
Apex Class:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
You can also do this without an ActionFunction, just use ActionSupport:
This code is a bit more efficient. I hope this helps.
-Glyn
HI GlynA,
Thanks for your answer,
Please help me now on this also.
Here I am getting the value as Id, I want to pass this Id to a method getrelateddata(), and using this value
I want fetch related list data...like account name, phone etc...
Now how should I pass the selected value to that method.
Thanks in advance.
vamshi,
Sorry I didn't see your question until now. I have added an action method to the controller and to the actionSupport in the VF page so that the page now displays a couple of fields from the selected account. If you add more fields in the page, be sure to add them to the query in the displayAccount() method of the controller. Here's the code:
If this helps, please click on the star to give kudos. Thanks!
-Glyn