Hi...again
I have 4 edit boxes and a button...
When you click the button it substracts from the first edit box the values of the second and third and the result is displayed in the fourth edit box.
The code is shown below
<html>
<head>
<title>calculator</title>
<SCRIPT LANGUAGE="JavaScript">
function sub(p1,p2,p3){
return parseInt(p1) - parseInt(p2) - parseInt(p3);
}
</SCRIPT>
</head>
<body>
<p>
<input type="number" value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"" name="first" size="15">
<input type="number" value = "" name="second" size="15">
<input type="number" value = "" name="third" size="15">
</p>
<p>
<input type="button" value=" Total " onClick="TOTALBOX.value= sub(first.value,second.value,third.value);" name="button">
<br>
<input type="text" value = "" name="TOTALBOX" size="15">
</p>
</body>
</html>
It works BUT if i dont insert a value to any of the first three edit boxes... in the total edit box the result is NaN!!!!
How can i do it in order to display a message saying (please insert values to all the edit boxes)
Thanks in advance...
I have 4 edit boxes and a button...
When you click the button it substracts from the first edit box the values of the second and third and the result is displayed in the fourth edit box.
The code is shown below
<html>
<head>
<title>calculator</title>
<SCRIPT LANGUAGE="JavaScript">
function sub(p1,p2,p3){
return parseInt(p1) - parseInt(p2) - parseInt(p3);
}
</SCRIPT>
</head>
<body>
<p>
<input type="number" value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"" name="first" size="15">
<input type="number" value = "" name="second" size="15">
<input type="number" value = "" name="third" size="15">
</p>
<p>
<input type="button" value=" Total " onClick="TOTALBOX.value= sub(first.value,second.value,third.value);" name="button">
<br>
<input type="text" value = "" name="TOTALBOX" size="15">
</p>
</body>
</html>
It works BUT if i dont insert a value to any of the first three edit boxes... in the total edit box the result is NaN!!!!
How can i do it in order to display a message saying (please insert values to all the edit boxes)
Thanks in advance...