increment a variable name
Posted: Tue Oct 20, 2009 10:37 am
Anyone know how I can increment a variable name within a loop?
I have:
I'm trying to get results as:
Hole1=
Hole2=
Hole3=
...
I have:
Code: Select all
var j=1;
for (j=1;j<=4;j++){
if (document.form1.elements['bh_hole_diam'+j].value > 0){
var Hole+j = Math.pow((document.form1.elements['bh_hole_diam'+j].value + 0.6),2);
}else{
var Hole+j = 0;
}
if ((document.form1.elements['bh_notch_w'+j].value > 0) && (document.form1.elements['bh_notch_h'+j].value > 0)){
var Notch+j = ((document.form1.elements['bh_notch_w'+j].value + 0.3) * (document.form1.elements['bh_notch_h'+j].value + 0.6));
}else{
var Notch+j = 0;
}
}
Hole1=
Hole2=
Hole3=
...