comportement de ma fonction
Petit screen de ma page:
http://img269.imageshack.us/img269/6...nstitreehf.jpg
La fonction qui me pose problème:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
function copier_ligne(id_magasin)
{
for(i = 0; i < nb_articles; i++){
if(document.getElementById('qte_'+id_articles[i]+'_'+id_magasin).value != "")
{
document.getElementById('qte_'+id_articles[i]+'_'+(id_magasin+1)).value = document.getElementById('qte_'+id_articles[i]+'_'+id_magasin).value;
decompte(id_articles[i]);
}
}
document.getElementById('qte_'+id_articles[0]+'_'+(id_magasin+2)).focus();
} |
Lorsque je retire la ligne avec decompte(id_articles[i]); le script me copie bien toute la ligne mais ne met pas a jour mes champs Stock puisque je n'apelle pas ma fonction.
Cependant, si je met la fonction décompte, le script ne me copie que la première valeur avec le décompte qui marche.
Je vous montre ma fonction décompte au cas ou:
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
|
//Fait le décompte pour un article en calculant la somme des qté article pour chaque magasin
function decompte(id_article)
{
var somme = 0;
/*var calculer = false;*/
for(i = 0; i < nb_magasins; i++){
if(!isNaN(document.getElementById('qte_'+id_article+'_'+(i+1)).value))
{
somme += Number(document.getElementById('qte_'+id_article+'_'+(i+1)).value);
}
}
if(somme <= qte_stock[id_article])
{
document.getElementById('valeur_stock_'+id_article).value = qte_stock[id_article] - somme;
nb_inputs = Math.ceil(nb_magasins / 20);
for(i = 1; i < nb_inputs; i++){
document.getElementById('repeat_'+i+'_'+id_article).value = document.getElementById('valeur_stock_'+id_article).value;
}
}
} |