salut tout le monde voici une fonction que j'utilisais pour dupliquer des lignes à mon tableau
en effet le script marche à merveille mais dés que j'ai ajouter du code php en milieu tout s'est arrêté!! la fonction devient non fonctionel
Code : 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 <table id="table" width="905" border="1"> <tr> <th width="108" scope="col"><div align="center">NATURE</div></th> <th width="155" scope="col">D.DEB.TRAV</th> <th width="155" scope="col">H.DEB.TRAV</th> <th width="155" scope="col">D.FIN.TRAV</th> <th width="155" scope="col">H.FIN.TRAV</th> <th width="137" scope="col">NOM EMPLOYé </th> </tr> <tr> <td rowspan="7"> <label></label> COUPE</td> <? echo "<script language=\"javascript\"> j=0; maxnbligne=6; function AddRow(){ j++; // Titre if (j<=maxnbligne){ var newRow = document.getElementById('table').insertRow(-1); // // var newCell = newRow.insertCell(0); newCell.align = 'center'; newCell.innerHTML = '<input type=\"text\" name=\"coul-aut-mat-pre['+j+']\" id=\"coul-aut-mat-pre['+j+']\" >'; // var newCell = newRow.insertCell(1); newCell.align = 'center'; newCell.innerHTML = '<input type=\"text\" name=\"coul-aut-mat-pre['+j+']\" id=\"coul-aut-mat-pre['+j+']\" >'; // var newCell = newRow.insertCell(2); newCell.align = 'center'; newCell.innerHTML = '<input type=\"text\" name=\"coul-aut-mat-pre['+j+']\" id=\"coul-aut-mat-pre['+j+']\" >'; // var newCell = newRow.insertCell(3); newCell.align = 'center'; newCell.innerHTML = '<input type=\"text\" name=\"qte_aut_mat_pre['+j+']\" id=\"qte_aut_mat_pre['+j+']\" >'; // var newCell = newRow.insertCell(4); newCell.align = 'center'; newCell.innerHTML = '<select name=\"nom_emp_ass\" id=\"nom_emp_ass\" >"; include("dynamique/connect.php"); $requeteSelection="SELECT CONCAT(nom_emp,' ',pre_emp) FROM employe"; $resSelection=mysql_query($requeteSelection) or die (mysql_error()); while ($ligne=mysql_fetch_array($resSelection)){ $valeur=$ligne[0]; echo "<option value='".$valeur."'> $valeur </option>"; } echo "</select>'; // var newCell = newRow.insertCell(5); newCell.align = 'center'; newCell.innerHTML = '<input name=\"clic\" type=\"button\" onClick=\"AddRow()\" value=\"ajouter ligne\">'; // var newCell = newRow.insertCell(6); newCell.align = 'center'; newCell.innerHTML = '<input type=\"button\" onclick=\"deleteCurrentRow(this)\" value=\"Supprimer\" alt=\"Delete\" >'; } } function deleteCurrentRow(obj) { var delRow = obj.parentNode.parentNode; var tbl = delRow.parentNode; if(tbl.getElementsByTagName('tr').length==1){ alert('Vous ne pouvez pas supprimer cette ligne');return false ; } tbl.removeChild(delRow); } AddRow(); </script>" ; ?>
avez vous une idée?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 newCell.innerHTML = '<select name=\"nom_emp_ass\" id=\"nom_emp_ass\" >"; include("dynamique/connect.php"); $requeteSelection="SELECT CONCAT(nom_emp,' ',pre_emp) FROM employe"; $resSelection=mysql_query($requeteSelection) or die (mysql_error()); while ($ligne=mysql_fetch_array($resSelection)){ $valeur=$ligne[0]; echo "<option value='".$valeur."'> $valeur </option>"; } echo "</select>';
Partager