Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/22/2017 in all areas

  1. Hi, InsertRecord is missing before field names in the following lines: document.getElementById("Regular_Hours").onchange=calculate; document.getElementById("OT_Hours").onchange=calculate; You may use onblur event in order to run function onchange, also I would recommend adding one more conditions in order to check that all the values which are being used in calculation are fulfilled with data <SCRIPT LANGUAGE="JavaScript"> function calculate() { var v_hours = parseFloat(document.getElementById("InsertRecordRegular_Hours").value); var v_hoursot = parseFloat(document.getElementById("InsertRecordOT_Hours").value); var v_rates = parseFloat(document.getElementById("InsertRecordRates").value); var v_ratesot = parseFloat(document.getElementById("InsertRecordRate_OT").value); if (isNaN(v_hours) || v_hours.length<1) { v_hours = 0; }else if (isNaN(v_hoursot) || v_hoursot.length<1) { v_hoursot = 0; }else if (isNaN(v_rates) || v_rates.length<1) { v_rates = 0; }else if (isNaN(v_ratesot ) || v_ratesot.length<1) { v_ratesot = 0; } var v_amount = ((v_hours * v_rates)+(v_hoursot * v_ratesot)); if ( isNaN(v_amount)){ v_amount = ""; } document.getElementById("InsertRecordAmount").value = v_amount; } document.getElementById("InsertRecordRegular_Hours").onblur=calculate; document.getElementById("InsertRecordOT_Hours").onblur=calculate; </SCRIPT> Cheers!
    1 point
×
×
  • Create New...