You need to sign in to do that
Don't have an account?
RAJU_DEEP
Population of one field by selection of another field in the same page
Hello Team.
My requirement is "i want to populate one text field value in visualforce page by selecting another field(by clicking on enter key) in the same page".
Scenario :
1. I have three text fields in my page Employee Id, Employee FName, Employee LName.
2. Whenever user will put Employee Id and press enter key on that field(Employee Id) the related data should be populated on another two fields(Employee FName, Employee LName) .
Please guide me how can i achieve this functionality.
Thanks & regards,
Raju Deep
Hi,
My assumption is that Employee FName and LName already exists along with the Id. If so, you can try with the below sample code.
In the above example, when you enter the Account Name and click on the Enter Button, AccountId will be rendered. Similarly you can modify the code to display the FName and LName.
Thanks
Hi Surekha,
Thanks for your quick response, I try this on my side then i let you know whether its working or not.
Regards,
Raju deep
Thanks for your reply I tried your code in my side its working fine but it was on the button click and as per my requirement it should work on text field onclick event.
The code which I am trying is given below:
Visualforce Page Code:
Controller Code:
public with sharing class ActionPageController { public String valueOne { get; set; } public String valueTwo { get; set; } public String valueThree { get; set; } public String fName { get; set; } public PageReference iWantMyJSValues() { valueOne = Apexpages.currentPage().getParameters().get('one'); valueTwo = Apexpages.currentPage().getParameters().get('two'); valueThree = Apexpages.currentPage().getParameters().get('three'); return null; } String emp1 = [select Last_Name__c from Employee_Detail__c where name =: fName].Last_Name__c; public String getEmp1(){ return emp1; } }
The above code generates following exception:
System.QueryException: List has no rows for assignment to SObject
Class.demoPackageTest.ActionPageController: line 20, column 19 Class.demoPackageTest.ActionPageController: line 1, column 27
Code which is underlined generates this exception, actually i am trying to build dynamic query when i give hard coded values in place of dynamic variable its working fine. Please guide me so that i could remove this exception and make my query dynamic .
Regards,
Raju Deep
Hi,
I guess, the variable "fName" is not having any value. Try printing that variable using system.debug.
If so, give the emp1 query inside the method "iWantMyJSValues".
Please let me know, if that works.
Thanks