computing values from a form optimized

admin

Administrator
Staff member
I have a script that I think can be more compact, but I'm just learing and would like some gudiance if possible.What I am trying to do I have a function that looks like this: form.gradepoints1.value = form.grade1.value*form.hours1.value but it needs to appear 40 times. Is there a way to use a loop instead of 40 versions of this same string with the value 1-40: form.gradepoints1.value = form.grade1.value*form.hours1.value form.gradepoints2.value = form.grade2.value*form.hours2.value etc... form.gradepoints40.value = form.grade40.value*form.hours40.value I tried using: var x; for (x = 1; x < 41; x++) { form.gradepoints[x].value = form.grade[x].value*form.hours[x].value } But nothing computed. Any suggestions?
 
Back
Top