function calcul() {
salaire = window.parseInt(document.myForm.txtSalaire.value);
temps = window.parseInt(document.myForm.txtTemps.value);
for (i = 0; i < monnaie.length; i++) {
profit = monnaie[i] - (salaire/DIVISEUR) * temps;
profit = profit.toFixed(3);
document.myForm.txtMonnaie[i].value = monnaie[i] + "$";
document.myForm.txtProfit[i].value = profit;
}
}
... <input type="text" name="txtMonnaie0"/>
I want to run through all my inputs to set new values to ‘name=”txtMonnaie[]”‘ and txtProfit[] using i as the parameter.
myForm.txtMonnaie is undefined.
Change:
To
If you have multiple elements with names like
txtProfit0,txtProfit1,txtProfit2, …browser will not create an array with name txtProfit in
document.myForm. There you will find just a list of properties likedocument.myForm.txtProfit0,document.myForm.txtProfit1… and you can access them using index, just like it is shown above