Use functionName.arguments to reference the arguments
|
|
<HTML> <HEAD> <TITLE> Add all of the numbers </TITLE> <SCRIPT> function addNums () { var theAnswer = 0; for (var i = 0; i < addNums.arguments.length; i++) { var theNum = Number(addNums.arguments[i]); theAnswer += theNum; } return theAnswer; } </SCRIPT> </HEAD> <BODY> <FORM Name="theForm"> <INPUT Type=Text Name="num1"> <INPUT Type=Text Name="num2"> <INPUT Type=Text Name="num3"> <INPUT Type=Text Name="num4"> <INPUT Type=Button Value="Add Them" onClick='document.write(addNums(theForm.num1.value,theForm.num2.value,theForm.num3.value,theForm.num4.value));'> </FORM> </BODY> </HTML>
|
|
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
|