Guys,
I have a hopefully small problem. I have a table that I am going to use to enter employee's time into. A dropdown box at the top of the page selects a group of users, which then populates the form. That part works great. For the form itself, I am using arrays to store the information, as in:
Now, what I would love, is to have additional columns that do math operations on that row, e.g. a column of applied ratio that divides the hours billed by potential hours.Code:echo '<td><input type="text" name="potential[]" size="2"/></td>';
What I have tried so far is a simple function as in:
However, this pulls data from a specific form element. I'd like to loop over all the form elements, but I'm not quite sure how to go about this. Can I loop over an input array like this? Ideally, I will have aCode:function appliedRatio() { var tot = document.time.potential; var act = document.time.billable; var ar = 100*(parseInt(act.value) / parseInt(tot.value)); document.getElementById("ar").value = ar;
on each form element so everything automatically calculates, but I'm not sure how to get the javascript to loop over all rows of the table and set the values accordingly.Code:onchange="applied_ratio();"
Thanks