Thursday 10 November 2016

Passing Array to Java Script Function

You can an array to JavaScript function as an argument. In side of function you can handle this argument in any other programming language. Take a look on following example : 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Array to Java Script Function : Girfa</title>
<script language="javascript">
     function ardemo(ar)
     {
          
           for(i=0;i<ar.length;i++)
                document.write("[" +ar[i] + "] ");
          
          
     }
</script>
</head>


<body>
<h2 align="center">Passing Array to java script function</h2><hr />
<center>
Check : <input type="button" value="Click to check" onclick="ardemo(new Array('.jpg','.gif','.png'))" />
</center>
</body>

</html>

Download HTML File

No comments:

Post a Comment