Tableau javascript rempli avec des index d'un tableau array php.
Bonjour,
je construit un tableau javascript qui est indexé par des variables d'un autre tableau php array.
Les valeurs de ce tableau JS sont des éléments d'un formulaire . le tableau est rempli si je coche la ligne correspondante à l’élément <input> texte.
mais quand j'affiche mon tableau , j'obtiens des séparateurs comme ça :
Code:
,Produits PF,Produits ATQ,Produits Financiers,,Charges PF,,,,,Produits de location
Pourquoi les séparateurs s’incrémentent quand on descends par rapport aux lignes ?
Quels est le problème selon vous ?
voici le code HTML généré quand.
Code:
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="budget_css.css" />
<title>Modifier un chapitre</title>
</head>
<script type="text/javascript">
/**
* Méthode qui sera appelée sur le click du bouton
*/
function aff_param(tab_id)
{
var tab_chapitre = new Array();
for (i=0; i<tab_id.length; i++)
{
id_ligne=tab_id[i];
if (document.getElementById('labox'+id_ligne).checked)
{
val_chapitre= document.getElementById('chapitre'+id_ligne).value;
tab_chapitre[id_ligne]=val_chapitre;
}
}
alert(tab_chapitre)
}
</script>
<body >
<div id="formulaire">
<form name="test" method="post" action="" >
<fieldset ><legend><b>chapitre à modifier</b></legend>
<table border="1" style="border-collapse:collapse" align="center" width="60%">
<thead>
<tr>
<th>Chapitre</th>
<th>A modifier</th>
</tr>
</thead>
<tbody>
<tr>
<td width="10%">
<input type="text" name="chapitre[9]" id="chapitre9" size="15" value="Autres Charges" />
</td>
<td>
<input type="checkbox" name="labox[9]" id="labox9" value="9" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[4]" id="chapitre4" size="15" value="Autres Produits " />
</td>
<td>
<input type="checkbox" name="labox[4]" id="labox4" value="4" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[7]" id="chapitre7" size="15" value="Charges Administratives" />
</td>
<td>
<input type="checkbox" name="labox[7]" id="labox7" value="7" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[6]" id="chapitre6" size="15" value="Charges AT" />
</td>
<td>
<input type="checkbox" name="labox[6]" id="labox6" value="6" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[8]" id="chapitre8" size="15" value="Charges Financières" />
</td>
<td>
<input type="checkbox" name="labox[8]" id="labox8" value="8" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[5]" id="chapitre5" size="15" value="Charges PF" />
</td>
<td>
<input type="checkbox" name="labox[5]" id="labox5" value="5" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[2]" id="chapitre2" size="15" value="Produits ATQ" />
</td>
<td>
<input type="checkbox" name="labox[2]" id="labox2" value="2" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[10]" id="chapitre10" size="15" value="Produits de location" />
</td>
<td>
<input type="checkbox" name="labox[10]" id="labox10" value="10" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[3]" id="chapitre3" size="15" value="Produits Financiers" />
</td>
<td>
<input type="checkbox" name="labox[3]" id="labox3" value="3" />
</td>
</tr>
<tr>
<td width="10%">
<input type="text" name="chapitre[1]" id="chapitre1" size="15" value="Produits PF" />
</td>
<td>
<input type="checkbox" name="labox[1]" id="labox1" value="1" />
</td>
</tr>
<tr align="center">
<td colspan="3">
<input type="button" name="envoi_mod_chapt" value="Modifier les données" onclick='
var objJsonJS = ["9","4","7","6","8","5","2","10","3","1"]; aff_param(objJsonJS); '/>
</td>
</tr>
</tbody>
</table>
</fieldset>
</form>
</div>
</body>
</html> |
Merci de vos aides.
Cordialement.