Setting Form Vars Dynamically(Simple-ish)
Posted: Wed Sep 16, 2009 10:34 am
So, I have the following code:
So basically I have hidden fields named "t1part1score" "t1part2score" etc and using a loop(above) I want to set 8 or so variables. Now I know at the momment the 'K' loop is useless, but that will be changed once I have done some other stuff(As stated by the comment). Basically instead of it trying to access 'hiddenVarName' I want it to try to access whatever is stored in the variable 'hiddenVarName'.
Think that made sense, I hope so, been playing around for a while now with no luck
Thanks,
Oscardog
Code: Select all
for(k = 1; k < 2; k++) { //Change to k < 3 sometime!
for(j = 0; j < 4; j++) {
var teamPartName = 'partnership' + j + 'total';
var teamPartValue = document.getElementById(teamPartValue).innerHTML;
teamPartValue = Number(teamPartValue);
var hiddenVarNum = j + 1;
var hiddenVarName = 't' + k + 'part' + hiddenVarNum + 'score';
document.scoresheetform.hiddenVarName.value = teamPartValue;
}
}Think that made sense, I hope so, been playing around for a while now with no luck
Thanks,
Oscardog