How to change the content of a variable to zero if isNaN
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7708067/when-i-press-enter-i-get-isnan-but-the-value-is-a-number">When I press enter I get isNaN, but the value is a number</a>  </p>
</blockquote>



<p>I turn in my homework last Sunday.It was sent back to me for correction because the isNaN value was returned to the Total textbox.I thought that is what is was programmed to do. Instead, according to her, "The isNaN function will examine the variable and determine if the variable holds non-numeric data, then the next statement will change the content of the variable to set to zero," which has me confused. Any suggestions Here is the code. *The "return;" statements were not a syntax error before I made changes. Here is the link to the uploaded file: ciswebs.smc.edu/cis54/tyson_schweidel/homework2.htm</p>

<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Price Calculator&lt;/title&gt;
&lt;script type="text/javascript"&gt;

function fixOrder()
{
var numPrice = parseFloat(document.getElementById("cost").value);
var taxP = parseFloat(document.getElementById("tax").value);
var total = parseFloat(document.getElementById("total").value);

}

if (isNaN(numPrice)){

    alert("Sorry,you must enter a numeric value to place order");

if (isNaN(taxP))
    alert("Sorry, you must enter a numeric tax value to continue");
    return; //gets syntax error
}


var tax = (numPrice * taxP)/100;{
var total = numPrice + tax;
numPrice = 0;
taxP = 0;
    document.getElementById("total").value = "$" + total.toFixed(2);
return; //gets syntax error
}
&lt;/script&gt;

&lt;/head&gt;

&lt;body bgcolor="#00f3F1"&gt;


&lt;h1 align="left"&gt;Price Calculator&lt;/h1&gt;

&lt;form name="form"&gt;
&lt;p&gt;
Price:  &lt;input type="text" id="cost" name="cost" value="" onchange="fixOrder();"/&gt;
&lt;/p&gt;
&lt;p&gt;
Tax: &amp;nbsp;
&lt;input type="text" id="tax" name="tax" value="" onchange="fixOrder();"/&gt;
&lt;/p&gt;
&lt;p&gt;
Total: 
&lt;input type="text" id="total" name="total" value="" disabled="disabled();"/&gt;
&lt;/p&gt;
&lt;/form&gt;
</code></pre>

<p>
</p>
