2 dropdown list created by jQuery using ajax

2 dropdown list created by jQuery using ajax

Hi,

I have 1 dropdown list that list all employers (option value is the employer ID).
When user select in this list an employer, i create (in jQuery / AJAX) another dropdown list with contact person working for the selected employer.
when user select a contact person from this second list, i would like to display the contact person email into a simple input textbox.

my problem is that selecting the contact person does not display his email into the input textbox.

using FireBug i saw that my second list (contact persons) do not run the ajax call :(

here is my code:
  1. function ajaxGetContacts(){
  2. var targ = jQuery("select[name='jform[employer_id]']");
  3. var url="index.php?option=com_rgtmyra&view=job&layout=edit&task=job.getcontacts&emp_id="+targ.val();
  4. var a=new Request.JSON({
  5. url:url,
  6. method:'get',
  7. onSuccess: function(response){
  8. jQuery('.updated-contact').html(response.html);
  9. }
  10. }).send();
  11. }
  12. function ajaxGetContactEmail(){
  13. var targ = jQuery("select[name='jform[contact_id]']");
  14. alert("contact id "+targ.val());
  15. var url="index.php?option=com_rgtmyra&view=job&layout=edit&task=job.getcontactemail&c_id="+targ.val();
  16. var a=new Request.JSON({
  17. url:url,
  18. method:'get',
  19. onSuccess: function(response){
  20. jQuery("input[name='jform[application_email]']").val(response.html);
  21. }
  22. }).send();
  23. }

  24. jQuery("#jform_employer_id").change(
  25. function(){
  26. alert("change employer ID");
  27. ajaxGetContacts();
  28. });
  29. jQuery("#jform_contact_id").change(
  30. function(){
  31. alert("change contact ID");
  32. ajaxGetContactEmail();
  33. });

  34. // to initialize the form
  35. ajaxGetContacts();
  36. ajaxGetContactEmail();
I know that both ajax methods and their return value are ok because i tested them..

i just have the feeling that when the first dropwdown is created, the function:
  1. jQuery("#jform_contact_id").change(
  2. function(){
  3. alert("change contact ID");
  4. ajaxGetContactEmail();
  5. });
is not available... 

any idea ?
thx.