bonjour à tous ,

voila j'ai un formulaire de contact dans une boucle while ( il peut donc y avoir plusieurs contact ) .

se formulaire est validé automatiquement via jquery des que l'on change un champ du formulaire .

le problème que je rencontre c'est qu'il ne prend en compte les changements que sur le premier résultat , si j'essaie de modifier mon deuxième contact , cela ne fonctionne pas .

j'ai donc essayer de rajouter un $i sur la class de l'input qui correspond a l'idcontact pour que la fonction jquery en tienne compte, mais sans succès

voila le code et merci pour votre aide , sachant que je débute en js , alors soyez indulgent

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<div id="bloc_infos_client_1">
      <label>Information g&eacute;n&eacute;rale client</label></br></br>
       <div id="bloc_infos">
      <table border="1" cellpadding="2" width="98%">
   <tr>
      <th width="1%">Type</th>
      <th width="1%">Civilité</th>
      <th width="2%">Nom</th>
      <th width="1%">Prénom</th>
      <th width="1%">Téléphone</th>
      <th width="1%">Portable</th>
      <th width="1%">Fax</th>
      <th width="5%">Mail</th>
   </tr>
     <?php
    $resultats=$pdo->query("SELECT * FROM Contact,ContactType,ContactCivilite WHERE IdRepertoire = '".$result->IdRepertoire."' AND Contact.IdContactType = ContactType.IdContactType  AND Contact.IdContactCivilite = ContactCivilite.IdContactCivilite ORDER BY Contact.IdContactType");
    $resultats->setFetchMode(PDO::FETCH_OBJ);
    while( $resultcon = $resultats->fetch() )
    {
        ?>
 
      <tr>
 
       <script type="text/javascript">
     $(document).ready(function() {
    $('select[class="IdContactType"]').on('change', function() {
        $.post('valid_IdContactType.php?IdContact=<?php echo ($resultcon->IdContact);?>', {
            'IdContactType' : $('select[name="IdContactType"]').val()
             
             
             
        }, function(response) { // onSuccess
            console.log(response);
        }, 'json');
    });
});
     </script>
      <td><select  class="IdContactType" name="IdContactType">
      <option selected="selected"><?php echo ($resultcon->ContactType);?></option></br>
      <?php
      $resultat=$pdo->query("SELECT * FROM ContactType WHERE IdContactType NOT LIKE '".$resultcon->IdContactType."'");
      $resultat->setFetchMode(PDO::FETCH_OBJ);
      while( $resultct = $resultat->fetch() )
      {
      echo '<option value="'.$resultct->IdContactType.'">'.$resultct->ContactType.'</option></br>';
      }
      ?>
      </select>
      </td>
      <script type="text/javascript">
     $(document).ready(function() {
    $('select[class="IdContactCivilite"]').on('change', function() {
        $.post('valid_IdContactCivilite.php?IdRepertoire=<?php echo ($result->IdRepertoire);?>&IdContact=<?php echo ($resultcon->IdContact);?>', {
            'IdContactCivilite' : $('select[name="IdContactCivilite"]').val()
             
             
             
        }, function(response) { // onSuccess
            console.log(response);
        }, 'json');
    });
});
     </script>
      <td><select  class="IdContactCivilite" name="IdContactCivilite">
      <option selected="selected"><?php echo ($resultcon->Civilite);?></option></br>
      <?php
       
      $resultat=$pdo->query("SELECT * FROM ContactCivilite WHERE IdContactCivilite NOT LIKE '".$resultcon->IdContactCivilite."'");
      $resultat->setFetchMode(PDO::FETCH_OBJ);
      while( $resultCC = $resultat->fetch() )
      {
          print_r($resultCC->IdContactCivilite);
      echo '<option value="'.$resultCC->IdContactCivilite.'">'.$resultCC->Civilite.'</option></br>';
      }
      ?>
      </select>
      </td>
      <?php
     $i = ($resultcon->IdContact);
     ?>
     <script type="text/javascript">
     $(document).ready(function() {
    $('input[class="info_gen_client-<?php echo $i;?>"]').on('blur', function() {
        $.post('valid_info_gen_client.php?IdContact=<?php echo $i;?>', {
            'IdContact' : $('input[name="IdContact"]').val(),
            'nom' : $('input[name="nom"]').val(),
            'prenom' : $('input[name="prenom"]').val(),
            'tel' : $('input[name="tel"]').val(),
            'Portable' : $('input[name="Portable"]').val(),
            'Fax' : $('input[name="Fax"]').val(),
            'email' : $('input[name="email"]').val()
             
             
        }, function(response) { // onSuccess
            console.log(response);
        }, 'json');
    });
});
     </script>
 
      <input style="width:98%;" type="hidden" class="info_gen_client-<?php echo $i;?>" name="IdContact" value="<?php echo ($resultcon->IdContact);?>"/>
      <td><input style="width:98%;" type="text" class="info_gen_client-<?php echo $i;?>" name="nom" value="<?php echo ($resultcon->Nom);?>"/></td>
      <td><input style="width:98%;" type="text" class="info_gen_client-<?php echo $i;?>" name="prenom" value="<?php echo ($resultcon->Prenom);?>"/></td>
      <td><input style="width:98%;" type="text" class="info_gen_client-<?php echo $i;?>" name="tel" value="<?php echo ($resultcon->tel);?>"/></td>
      <td><input style="width:98%;" type="text" class="info_gen_client-<?php echo $i;?>" name="Portable" value="<?php echo ($resultcon->Portable);?>"/></td>
      <td><input style="width:98%;" type="text" class="info_gen_client-<?php echo $i;?>" name="Fax" value="<?php echo ($resultcon->Fax);?>"/></td>
      <td><a href="mailto:<?php echo ($resultcon->email);?>"><input style="width:98%;" type="text" class="info_gen_client-<?php echo ($resultcon->IdContact);?>" name="email" value="<?php echo ($resultcon->email);?>"/></a></td>
      </tr>
    <?php
    }
    ?>
 
   </table>
   </div>