Sunday, January 12, 2014

JavaScript function (methods)

1) Simple example of function

<html>
<body>
<script>  
function love()
{  
alert("Love is a feeling");  
}  
</script>
<form> 
<input type="button" onclick="love()" value="Function"/>
</form>
</body>
</html>

2)  Function Arguments


<html>
<body>
<script>
function tri(m) //argument
{
alert(m*m*m);
}
</script>
<form>
<input type="button" value="click" onclick="tri(5)">
</form>
</body>
</html>

3)  Function with Return Value

<html>
<body>
<script>
            function gujrati()
            {
                     return "kem chho?"
            }
            document.write(gujrati());
</script>
</body>
</html>

No comments:

Post a Comment