Pass integer to function : Function Parameters « Function « JavaScript Tutorial






<html>
<head>
<script language="JavaScript" type = "text/javascript">
<!--

function DisplayMsg(NumVal) {
    if (NumVal == 1) {
       status = "Type your name in the field" ;
    }
    if (NumVal == 2) {
       status = "Type your phone number in the field"
    }
}
//-->
</script>
<title>Keyboard Event</title>
</head>
<body>
<form name="form1">
<b>Name:</b>&nbsp; <input type = "text" name = "text1" onFocus="DisplayMsg(1)" size="20"><P>
<b>Phone:</b> &nbsp;<input type = "text" name = "text2" onFocus="DisplayMsg(2)" size="20"></p>
</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