Click to See Complete Forum and Search --> : FORM script help please


Steve S
12-19-2003, 01:00 PM
I have built a javascript / html form calculator. I have intentionally limited the maximum size of the permissible numeric input.

How can I replace the "Not a Number" - "NaN" result with text in the result field when someone inputs a number greater than the acceptable values?

(it is a job quote calculator. Any job greater than a specific amount of time is on an Individual Cost Basis - I want to return "ICB" instead of "NaN")

requestcode
12-19-2003, 01:16 PM
Can we see your code? That would help to come up with an answer.

Steve S
12-19-2003, 01:20 PM
Here is the code:

function pricePerMailbox(num)
{
if (num > 0 && num < 100)
{ return 150/num }
else if (num >=100 && num <=249)
{ return 350/num }
else if (num >=250 && num <=499)
{ return 500/num }
else if (num >=500 && num <=999)
{ return 750/num }
}

function dollarRound(num)
{
return Math.round(num)
}

function calcRound(num)
{
result="$"+Math.floor(num)
n = result.length
if (num>1000 && num<999999) {
result="$"+result.substring(1,n-3)+","+result.substring(n-3,n)
}
if (num>1000000) {
result = "$"+result.substring(1,n-6)+","+result.substring(n-6,n-3)+","+result.substring(n-3,n)
}
return(result)
}