Hello,
I'm a PHP coder, but my client is getting me out of my comfort zone by doing a bit of javascript.
I've got basic functionality set up, but I'm just coming across one issue. The thing they want is a simple percentage calculator, where someone enters a value, a percentage and the site then performs calculations based on these values.
It's all working fine, except when you actually physically write a percentage sign. I'm looking for some way of stripping out percentage signs. I tried the replace() function, but that just stopped the calculator working. Any advice appreciated, here's my code:
function calculate()
{
a=Number(document.getElementById("edit-gpcalculatorcost").value);
b=Number(document.getElementById("edit-gpcalculatorpercentage").value);
b3=b;
b2=b3/100;
c=a/(1-b2);
c2=Math.round(c*100)/100;
c3=c2*1.2;
c4=Math.round(c3*100)/100;
document.getElementById("edit-gpcalculatortotal").value=c4;
}