Forum Moderators: open
How would i execute one function from inside another function?
Each seperate form is exactly the same. The only difference is each of the forms pertain to a different person. I just need the same operations performed for each form.
i have 50 identical forms on different <DIV>'s... I want to click one button to call on a different function for each div, each function inserting the name of the div or whatever into the calculating function, so that i can use this one function to calculate the individual results of each form and return these values. it's a time clock.
Here's an example of how to call one function (called myFunction) 50 times, each time passing it a different div id as an argument. The divs ids are called myDiv1, myDiv2, myDiv3 etc. It works by concatenating (sticking together with the plus sign) a string "myDiv" with the value of the counter (the variable called i).
myFunction(argument) {
alert(argument)
}
for (var i = 1; i <= 50; i++) {
var myDivName = "myDiv" + i;
myFunction(myDivName);
}
function loop(){
for (var i = 0; i <= 48; i++) {
var arg = "document.forms["+i+"]";
calculate(arg);
}
}
<FORM>
<input type="button" value="calculate" onClick="loop()"> //javascript error tells me that object does not support this action
</FORM>