TechFundu

  • Increase font size
  • Default font size
  • Decrease font size
Welcome Guest,  Login | Join Now
Home Forum

Copying result values to a text area in jquery
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Copying result values to a text area in jquery
#52
Copying result values to a text area in jquery 2 Years, 5 Months ago Karma: 0
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.
roselin
Fresh Boarder
Posts: 9
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#53
Re:Copying result values to a text area in jquery 2 Years, 5 Months ago Karma: 0
I solved this myself. Sorry to ask such a silly question. Here goes the modified script :

$('#addEmployee').click(function(){
$.ajax({
url: 'searchEmployee.do?method=searchEmployee',
type: 'GET',
data: {employeeId: $('input#emp').val()},
success: function(data) {
if($('textarea#employee_id_textarea').val() ==""){
$('textarea#employee_id_textarea').val(data) ;
}
else {
$('textarea#employee_id_textarea').val($('textarea#employee_id_textarea').val() +"," +data);
}
$('div#resultEmp').html("").css("padding",0);
$('input#emp').val("");
}
});

Thanks,
Rose
roselin
Fresh Boarder
Posts: 9
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
get the latest posts directly to your desktop
Follow us on Twitter