How To assign a value from postgres sql query to a field in frontend using javascript

Viewed 61

I Actually Have 2 fields in the front end. In which In the first field i will Auto Search the employee name for which I have Written A postgre sql query.

Now my Requirement Is As soon i select The Employee Name I need His job title To be Displayed in the next feild.

How Can I do That Using Java Script. Please Find The Query below

select ei.id,ei.employee_name,ro.name,um.role_id from manager_mapping mm 
left join employee_info ei on mm.typeid = ei.id  
left JOIN user_master um on um.id = ei.user_master_id   
left join role ro on ro.id = um.role_id   
where ei.employee_name ilike %:searchtxt% and ro.name='ROLE_JDM' or 
ro.name='ROLE_HEADOFF' and um.enabled = true 

In the Above Query I want the value the value of ro.name to be displayed automatically when i select the employee name

1 Answers

Create api and from front end using ajax or fetch call those api. This api will internally call the service which will call the dao which will eventually run this query.

Then send the result of the query as the return of the api. Once the ajax is successful you can assign the values to the variable in javascript

Related