Hi again,
Thanks to 'twist' this function now executes but I have a problem getting my last line to work. CoutTotale refers to a textbox created within the form and to which I want to send the final calculated value.
function calcul(form)
{
for(var i=0;i<form.nomb.value; i
{ var c13="text"+i+"13";
var c17="text"+i+"17";
var c21="text"+i+"21";
//document.write(form[c13].value);
var r= parseInt(form[c13].value) + parseInt
(form[c17].value) + parseInt(form[c21].value);
//document.write(r);
var cr ="text"+i+"22";
form[cr].value =r;
}
var CombTotal=0;
for(var d=0;d<form.nomb.value;d++)
{ var cr ="text"+d+"22";
CombTotal+=parseInt(form[cr].value);
}
//document.write(CombTotal);
form.CoutTotale.value = CombTotal;
//neither does: form[CoutTotale].value=CombTotal;
}
Prob2:Also, when the last line is left out so the function executes, I get a new white screen showing my document.write output..why isn't it writing to the same scrren on which my button and the textboxes are found?
Prob3:In body of document,tried calling function as below replacing the last line in the function calcul(form) with return CombTotal, got an error alertwhen executed:
<input type="button" value="Calculer couts" onClick="this.form.CoutTotale=calcul(this.form)" >
Thanks to 'twist' this function now executes but I have a problem getting my last line to work. CoutTotale refers to a textbox created within the form and to which I want to send the final calculated value.
function calcul(form)
{
for(var i=0;i<form.nomb.value; i
{ var c13="text"+i+"13";
var c17="text"+i+"17";
var c21="text"+i+"21";
//document.write(form[c13].value);
var r= parseInt(form[c13].value) + parseInt
(form[c17].value) + parseInt(form[c21].value);
//document.write(r);
var cr ="text"+i+"22";
form[cr].value =r;
}
var CombTotal=0;
for(var d=0;d<form.nomb.value;d++)
{ var cr ="text"+d+"22";
CombTotal+=parseInt(form[cr].value);
}
//document.write(CombTotal);
form.CoutTotale.value = CombTotal;
//neither does: form[CoutTotale].value=CombTotal;
}
Prob2:Also, when the last line is left out so the function executes, I get a new white screen showing my document.write output..why isn't it writing to the same scrren on which my button and the textboxes are found?
Prob3:In body of document,tried calling function as below replacing the last line in the function calcul(form) with return CombTotal, got an error alertwhen executed:
<input type="button" value="Calculer couts" onClick="this.form.CoutTotale=calcul(this.form)" >