Hi All, I have a below jquery function to search the employee data and show the result. i have a text box in which the user type in the empid and click on search. Once user clicks on search it shows the employee detail such as name, sex, race etc below the textbox.
$('#addEmployee').click(function(){ $.ajax({ url: 'searchEmployee.do?method=searchEmployee', type: 'GET', data: {employeeId: $('input#emp').val()}, success: function(data) { $('div#resultEmp').css("padding","10px 0 10px 0").html(data); } }); }); Once i get the proper employee data such as empid, name, race etc. I have a href link for the empid . I click on the emp id link and i copy that employee id into the textarea i have right below the results. Now the user doesn't want to click on the emp id to copy the value on the textarea. They just want if data from backend is correct directly copy to the textarea without clicking on empid(which i am showing as results after clicking search). To copy emp id from the link to textarea i am calling another javascript as below : // Function for copying Employee Id to the textarea. function selectEmp(id) { if($('textarea#employee_id_textarea').val() ==""){ $('textarea#employee_id_textarea').val(id) ; } else { $('textarea#employee_id_textarea').val($ ('textarea#employee_id_textarea').val() +"," +id); } $('div#resultEmp').html("").css("padding",0); $('input#emp').val(""); } Could you please advise how i can do that? After result success i want to copy the empid directly to the textarea without clicking. I don't even know if i have made myself clear. Please let me know if you need more information. Thanks in advance.