Advertisement
Guest User

Untitled

a guest
Mar 6th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(".select-zone").change(function () {
  2.  
  3.     var select = $(".select-lieu");
  4.     var value = $(this).val();
  5.  
  6.     select.empty().append("<option value='-1'>Lieu / Salle</option>");
  7.     if (value != -1) {
  8.         $.ajax({
  9.             url: Routing.generate('admin_default_getlieusallebyzone', {id: value}),
  10.             dataType: 'json'
  11.         }).done(function (data) {
  12.             $.each(data, function (i) {
  13.                 $.each(data[i], function (val1) {
  14.  
  15.                     var id = val1.id;
  16.                     var libelle =val1.nom;
  17.                     var numero = val1.numero;
  18.                     if (numero != undefined) {
  19.                         select.append("<option value=" + id + ">" + libelle + " - " + numero + "</option>");
  20.                     } else {
  21.                         select.append("<option value=" + id + ">" + libelle + " </option>");
  22.                     }
  23.  
  24.                 });
  25.  
  26.                 $.each(data[i], function (val2) {
  27.                     var id = val2.id;
  28.                     var libelle = val2.nom;
  29.                     var numero = val2.numero;
  30.                     if (numero != undefined) {
  31.                         select.append("<option value=" + id + ">" + libelle + " - " + numero + "</option>");
  32.                     } else {
  33.                         select.append("<option value=" + id + ">" + libelle + " </option>");
  34.                     }
  35.  
  36.                 });
  37.                 select.prop('disabled', false);
  38.             })
  39.         });
  40.     }
  41.  
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement