A Function That Returns the Sum of Three Numbers (Stripped-Down Version) : Number Data Type : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Number Data Type »

 

A Function That Returns the Sum of Three Numbers (Stripped-Down Version)



/*

Learn How to Program Using Any Web Browser
by Harold Davis 

Apress CopyRight 2004

ISBN: 1590591135
*/
<HTML>
<HEAD>
<TITLE> 
   Add three numbers 
   </TITLE>
<SCRIPT
   function addThreeNums (inOne, inTwo, inThree) { 
      var inOne = Number(inOne)
      var inTwo = Number(inTwo)
      var inThree = Number(inThree)
      return Number(inOne + inTwo + inThree)
   
   </SCRIPT>
</HEAD>
<BODY>
<FORM Name="theForm">
<INPUT Type=Text Name="num1">
<INPUT Type=Text Name="num2">
<INPUT Type=Text Name="num3">
<INPUT Type=Button Value="Add Them" 
         onClick='document.write("The sum of the three numbers is " 

addThreeNums(theForm.num1.value,theForm.num2.value,theForm.num3.value));'>
</FORM>
</BODY>
</HTML>
           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Number Data Type