Jump to content

jscriptnoob

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by jscriptnoob

  1. Will need to deal with the CSS style sheet. Looks like it's defaulting <p> tags for some reason. Thanks for the help!
  2. CSP is Content Service Protection. Each browser apparently requires one Firefox, Chrome, Opera and Safari all operate off the same one and IE has it's own so I've read. As for the link its here.
  3. I checked the error log and it gave me only one error which I changed to the correct syntax provided. However, now I'm getting an error message saying that CSP is not enabled in my header and the script isn't allowed to run. Sounds to me like this is the issue here, my problem is I've done some research on it and understand that I basically have to allow the CSP for each browser to allow the script to run. I want to make sure I get it right. If that makes any sense?
  4. Thanks for the re-code! I understand to a degree what you did (learning what it all is and how it works). I have a problem though, I put the code in to Edge Code CC and do a "live preview" and it works like a charm. I copy the exact code verbatim and paste it in to a webpage and it doesn't work anymore. Again, probably something really stupid simple, but I can't see what it is.
  5. I know there's a few of these floating around, but none of them touch on what my issue is. Below is the code for my calculator including the html. The issue I'm having is that I think, as far as I can tell, my code to calculate which fields etc. is correct. The results just won't populate in to the total boxes like they should. I expect it's something simple, but this is my first real foray in to coding so I'm still really new at this. Thanks for all the help. function calculate() { var valA= 0; var valB= 0; var valC= 0; var ITCPer= 35%; var SRClVal= 55%; var totalA= 0; var totalB= 0; var totalC= 0; var Subtotal= 0; var GrandTotal= 0; if (document.ofrm.valA.value > "") { valA = document.ofrm.valA.value }; document.ofrm.valA.value = eval(valA); if (document.ofrm.valB.value > "") { valB =document.ofrm.valB.value }; document.ofrm.valB.value = eval(valB); if (document.ofrm.valC.value > "") { valC = document.ofrm.valC.value }; document.ofrm.valC.value = eval(valC); if (document.ofrm.valD.value > "") { valD = document.ofrm.valD.value }; document.ofrm.valD.value = eval(valD); if (document.ofrm.valE.value > "") { valE = document.ofrm.valE.value }; document.ofrm.valE.value = eval(valE); if (document.ofrm.valF.value > "") { valF = document.ofrm.valF.value }; document.ofrm.valF.value = eval(valF); if (document.ofrm.ITCPer.value > "") { ITCPer = document.ofrm.ITCPer.value }; document.ofrm.ITCPer.value = eval(ITCPer); if (document.ofrm.totalA.value > "") { totalA = document.ofrm.totalA.value }; document.ofrm.totalA.value = eval(totalA); if (document.ofrm.totalB.value > "") { totalB = document.ofrm.totalB.value }; document.ofrm.totalB.value = eval(totalB); if (document.ofrm.totalC.value > "") { totalC = document.ofrm.totalC.value }; document.ofrm.totalC.value = eval(totalC); if (document.ofrm.Subtotal.value > "") { Subtotal = document.ofrm.Subtotal.value }; document.ofrm.Subtotal.value = eval(Subtotal); if (document.ofrm.GrandTotal.value > "") { GrandTotal = document.ofrm.GrandTotal.value }; document.ofrm.GrandTotal.value = eval(GrandTotal); if (document.ofrm.SRClVal.value > "") { SRClVal = document.ofrm.SRClVal.value }; document.ofrm.SRClVal.value = eval(SRClVal); totalA = valA + valD * SRClVal; document.ofrm.totalA.value = dm(eval(totalA)); totalB = valB + valE * SRClVal; document.ofrm.totalB.value = dm(eval(totalB))}; totalC = valC + valF * SRClVal; document.ofrm.totalC.value = dm(eval(totalC)); Subtotal = totalA + totalB + totalC; document.ofrm.Subtotal.value = dm(eval(Subtotal)); GrandTotal = Subtotal * ITCPer; document.ofrm.GrandTotal.value = dm(eval(GrandTotal)); } <form method="POST" action="submitted.html" name="ofrm"> <table border="0" cellpadding="0" width="550" id="table2" name="ofrm"> <tr> <td width="250" height="31"><b>Item Description</b></td> <td align="center" width="100" height="31"><b>Value</b></td> <td align="right" height="31" width="60"><b>Project Length (months) </b></td> <td align="right" height="31" width="140"><b>Total</b></td> </tr> <tr> <td width="250">Labour Expenditures</td> <td align="center" width="100"> <input type="text" name="valA" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td> <td align="right" width="60"> <input type="text" name="valD" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td> <td align="right" width="140"> <input type="text" name="totalA" size="12" tabindex="99" onchange="calculate()"></td> </tr> <tr> <td width="250">Contract Expenditures</td> <td align="center" width="100"> <input type="text" name="valB" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td> <td align="right" width="60"> <input type="text" name="valE" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td> <td align="right" width="140"> <input type="text" name="totalB" size="12" tabindex="99" onchange="calculate()"></td> </tr> <tr> <td width="250">Materials (Consumed or Transformed)</td> <td align="center" width="100"> <input type="text" name="valC" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td> <td align="right" width="60"> <input type="text" name="valF" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td> <td align="right" width="140"> <input type="text" name="totalC" size="12" tabindex="99" onchange="calculate()"></td> </tr> <tr> <td width="250"> </td> <td align="center" width="100"> </td> <td align="right" width="60"> </td> <td align="right" width="140"> </td> </tr> <tr> <td width="250"> <p align="right"><b>SUB TOTAL:</b></td> <td align="center" width="100"> </td> <td align="right" width="60"> </td> <td align="right" width="140">$ <input readonly style="border:0px;" class="totals" name="GrandTotal" size="15" tabindex="99" onchange="calculate()"></td> </tr> <tr>
  6. Your issue it seems in in cell G91. Whatever formula you have there is rounding your number up to what appears to be the nearest whole number. Whereas your javascript formula rounds down. Otherwise the values are all the same when an "output" is required. That leaves G91 being the only difference. I could be wrong, but I'd start there and see if there's a discrepancy between the two formulas. What are you using to convert the excel to javascript?
×
×
  • Create New...