C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...







Understanding Events



This article explains about Javascript Events and their use



JavaScript comes with wide variety of events that are helpful in solving real world scenarios.The interesting thing in JavaScript is to create dynamic web pages that enhance user interaction.Javascript events help in building interactive web pages.

An event is defined as an item that fires based on action.

Commonly used events in JavaScript are:
onclick
onload
onmouseover
onkeypress

Here is simple example for Javascript click event. We are trying to fire a message in an alert box when the button is clicked.

1. Create FireMsg method in the script tag based on the technical requirement.
Here we need to place the code related to the action that is performed when a button is clicked
In this case we are just trying to fire a message in alert box. You may try for user Id and password validation as an assignment
2. Assign this method in onclick event of the button.

<html>
<head>
<script type="text/javascript">
<!--
function FireMsg()
{
alert("Button Clicked")
}
//-->
</script>
</head>
<body>

<input type="button" value="Click Me!" onclick="FireMsg()"><br />
</body>

Execution:


The way it executes is simple and straight forward. When user clicks on button it fires the corresponding event and the functionality related to that event is executed. So simple !!



  • Next Chapter: Important points to make a note about JavaScript

  • Previous Chapter: Math Object - Example

  • Tutorial Index



  • dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use