You need to sign in to do that
Don't have an account?
gaurav arora 33
Get Id from lookup inputfield.
I have a Code in which i am using apex:inputField for lookup field. when i am getting this field value in script it gives me the name of the record selected.
I want to get the ID of the record selected either in javascript variable or in apex controller.
I want to get the ID of the record selected either in javascript variable or in apex controller.
Page------------------------------->> <apex:page Controller="ApexParamController"> <script> function fire(){ var fr=document.getElementById('{!$Component.frm.acc}').value; alert('test:: '+fr); } </script> <apex:form id="frm"> <apex:inputfield value="{!contact.AccountId}" id="acc"/> <apex:commandButton onclick="fire();" value="Save" action="{!print}" /> </apex:form> </apex:page>
Class------------------->> public class ApexParamController { Public Contact contact{get;set;} public void print(){ contact = new Contact(); system.debug('Account::'+contact.AccountID); } }
All Answers
Its solved my issue.