Pass Form value to a function : Function Parameters « Function « JavaScript Tutorial






<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("sum:" +addThreeNums(theForm.num1.value,theForm.num2.value,theForm.num3.value));'>
</FORM>
</BODY>
</HTML>








7.3.Function Parameters
7.3.1.Pass value to a function
7.3.2.Pass number to a function
7.3.3.Pass integer to function
7.3.4.Pass Form value to a function
7.3.5.Use functionName.arguments to reference the arguments
7.3.6.Pass an array to a function