pgjacob Posted June 6, 2015 Report Share Posted June 6, 2015 I have two tables, one a general employee table (Payroll master) with emplyee id, payrate, etc. Another with weekly hours (Payroll journal). I have a submission datapage to enter hours. And in a Tabular datapage with a View of both these tables, I can calculate the weekly pay based on rate and hours. However, I can't seem to figure out how to capture this calculated field in the payroll journal table so its archived. I have tried JS but it doesn't work (I try to pull in the pay rate from master table in a virtual field based on employee ID, and use the entered value for regular hours). <SCRIPT LANGUAGE="JavaScript"> function calculateregpay() { var v_reghr = parseFloat(document.getElementById("InsertRecordPayroll_journal_Regular_Hours").value); var v_regpay = parseFloat(document.getElementById("InsertRecordPayroll_master_Pay_rate").value); var v_totalreghr = (v_reghr * v_ regpay); document.getElementById("InsertRecordPayroll_journal_Regular_Pay").value = (v_ totalreghr).toFixed(2); } /* On submitting the webform, the function calculate is executed */ document.getElementById("caspioform").onsubmit=calculateregpay; </SCRIPT> Kennethflit 1 Quote Link to comment Share on other sites More sharing options...
aam82 Posted June 8, 2015 Report Share Posted June 8, 2015 did you try preloading a value on page load, of 0, for hours? Also, I have a similar need, but instead of doing this, I've disabled deletions, and editing either value after submission. This way, a user cannot change values after the fact, and if a user deletes, but it was paid, it was only "marked for deletion" and omitted from reports, but not truly deleted. I think this accomplishes "Archiving," though I'm curious what you think. THanks Quote Link to comment Share on other sites More sharing options...
Jan Posted June 9, 2015 Report Share Posted June 9, 2015 Hello pgjacob, If I understand correctly, there are two misprints in the code: var v_totalreghr = (v_reghr * v_ regpay); document.getElementById("InsertRecordPayroll_journal_Regular_Pay").value = (v_ totalreghr).toFixed(2); Spaces break the code. And, if you use a Virtual field, the id of Virtual field is "cbParamVirtual1" (you can see more details about Ids and Names). I hope, it helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.