You need to sign in to do that
Don't have an account?
Akash Diwan.ax1657
Value of lookup field
I have a lookup field for contacts inside <apex:repeat> tag on a visual force page.
I want to get the account name of the selected contact in the lookup field & display it in a <apex:textarea>.
How can i achieve this?
There can be multiple lookup's which which will have same no of textarea's. Every time a contact is selected the corresponding textarea show get automatically populated with tha account name to which the selected contact refer's.
Thank you.
you can use apex action support
use the below mention code
Class:-
public class test
{
public contact ContactObj{get;set;}
public test()
{
ContactObj = new contact();
}
public void RelAccoutName()
{
for(integer i=0; i<MainList.size();i++)
{
contact con = [select id,name.account.name from contact where id=:ContactObj.LookupField__c];
if(ContactObjList[0].id == ContactObj.LookupField__c)
{
MainList[0].TextAreaField__c = con.account.name;
}
}
}
}
page:-
<apex:outputpanel id="panle1">
<table>
<apex:repeat var="con" value="{!MainList}">
<tr><td>Contact Lookup field
<apex:actionRegion>
<apex:inputfield value="{!ContactObj.LookupField__c}">
<apex:actionSupport event="onchange" rerender="panle1" action="{!RelAccoutName}">
</apex:actionSupport>
</apex:inputfield>
</apex:actionRegion>
</td>
<td>
textarea in which you want to show account
<apex:inputfield value="{!con.TextAreaField__c}"/>
</td>
</tr>
</apex:repeat>
</table>
</apex:outputpanel>
I belive this will solve your issue
which type of list is MainList ?
You mention you are using apex:repite so you must bind it with some kind of list ??
then only it work