We help IT Professionals succeed at work.

VbScript vs Javascript

kristinc
kristinc asked
on
How do I convert this VBScript to Javascript?

if frmOrderDetails.prov_tax.value = "AB" then
     frmOrderDetails.tax.value = Round(CDbl(frmOrderDetails.sub_total.value) * 0.07,2)
elseif frmOrderDetails.prov_tax.value = "BC" then
     frmOrderDetails.tax.value = Round(CDbl(frmOrderDetails.sub_total.value) * 0.14,2)
elseif frmOrderDetails.prov_tax.value = "YK" then
     frmOrderDetails.tax.value = Round(CDbl(frmOrderDetails.sub_total.value) * 0.07,2)
end if

Any suggestions?
Comment
Watch Question

Author

Commented:
I am actually looking more at the Round and CInt functions and how go about doing this in Javascript.
Finance Systems Developer
Commented:
Try this, I'm not sure what those VBScript functions do:

switch (frmOrderDetails.prov_tax.value) {
  case "AB":
    frmOrderDetails.tax.value=(Math.round(parseFloat(frmOrderDetails.sub_total.value)*0.07*100)/100;
     break
  case "BC":
    frmOrderDetails.tax.value=(Math.round(parseFloat(frmOrderDetails.sub_total.value)*0.14*100)/100;
     break
  case "YK":
    frmOrderDetails.tax.value=(Math.round(parseFloat(frmOrderDetails.sub_total.value)*0.07*100)/100;
     break
  default:
    frmOrderDetails.tax.value=(Math.round(parseFloat(frmOrderDetails.sub_total.value)*0.07*100)/100;
}

Explore More ContentExplore courses, solutions, and other research materials related to this topic.