I Want to bring value of Picklist from one visual force page to another?

In I have got one Visual force page called edit. And another visual force page called Lookup.

On the Edit page I have a pick list field called Type: with value 1 , 2 ,3 Now On the lookup page on the lookup page when user click on car lookup on the edit page it opens Lookup visual force page. I need value of Type from the edit page on this lookup page.

Below is the code I used on edit page to take the value form Edit page in variable. And reference that on the lookup page.

var Type = document.getElementById('page:frm:pb:OppType').value;

I have tried using Document.getelementById but that Doesnot help. Would anyone please be able to help me with this?

  • Third paragraph of your question needs editing/rephrasing and a bit more detail. – abdn Oct 19 '15 at 19:16

One method might that you could always pass the value to the other VF page through the URL by a PageReference action on the button?

You'd first need to get the value of type which you should be able to get given you're already displaying the list, then on the button that calls the Edit page, something like this:

PageReference pageRef = New PageReference('/apex/Lookup?type=' + type);
return pageRef;

Where type is the (presumably) String variable.

'/apex/Lookup?type=' + type

Will redirect the user to your Lookup page, but more importantly pass in a parameter of containing the variable type.

In the Controller for your Lookup page, you could then use:

public String type = apexpages.currentpage().getparameters().get('type');

To get that value in your controller and process it from there.

Hopefully this goes some way in to helping you solve this problem!

  • Thanks for your efforts. And Sorry for the late reply. I was trying to implement the code given by you with different aspects but I couldn't get succeed – Ricky Oct 20 '15 at 20:31
  • Let me clarify few things here . Which I have not probably mentioned in question thinking I will be able to manage that part my self. In my org we use openPopup() and pass paramenters into that like baseURL,Width,Heigh where Variable baseurl in which we create for different fileters. Here is the code for Baseurl var BaseURL="/apex/Looup?txt=" + txt: if(Cond.) {baseurl = baseurl + "&txt2=" document.getElementbyId(page:form:pbs:carvalue).value; i have tried adding another condition for type if(opp.type != null) baseurl = baseurl+"&type=" + document.getElementbyId(page:form:pbs:Type).value; } – Ricky Oct 20 '15 at 20:43
  • I am sorry that looks nasty. Do you want me to add another question so that you can read that? – Ricky Oct 20 '15 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.