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
Roshan SahatiyaRoshan Sahatiya 

A simple visualforce page with two input fields - redirect to other VF page.

Hi All,

 

Can anyone out here provide some basic code for VFpage with two input fields and on click of a button, it should be able to pass the value of one of the input fields as the id to the next VF page URL .

 

Thanks in advance

 

 

Best Regards,

Roshan

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference:

<apex:page controller="inputflddemo" >

  <apex:form >

  <apex:inputField value="{!con.LastName}" />

  <apex:inputField value="{!con.accountid}"/>

  <apex:commandButton value="ClickHere" action="{!passvalue}"/>

  </apex:form>

</apex:page>

 

==========Apex Controller==========

 

public class inputflddemo {

 

public Contact con{get;set;}

public inputflddemo()

{

    con=new Contact();

}

 

public PageReference passvalue()

{

    PageReference pageRef = page.GridDemo;

    pageRef.getParameters().put('id',con.Accountid);

   

    pageRef.setRedirect(true);

    return pageRef;  

 

}

 

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.