CSS Exp - 7_20203B1002
CSS Exp - 7_20203B1002
Experiment No: 07
Resources required:
Hardware Software
Practical Significance:
A JavaScript executes in response to an event that occurs while a form is displayed on
the screen. An event is something the user does to the form, such as clicking a button,
selecting a radio button, or moving the cursor away from an element on the form. The
browser also fires events when the page finishes loading from the server.
Theoretical Background
<html>
<head>
<script> function
sayHello() {
alert("Hello World")
}
</script>
</head>
<body>
<p>Click the following button and see result</p>
<form>
<input type="button" onclick="sayHello()" value="Say Hello" />
</form>
</body>
</html>
These two event types will help you create nice effects with images or even with text
as well. The onmouseover event triggers when you bring your mouse over any element
and the onmouseout triggers when you move your mouse out from that element.
<html>
<head>
<script> function over() {
document.write ("Mouse Over");
}
function out() {
document.write ("Mouse Out");
}
</script>
</head>
<body>
<p>Bring your mouse inside the division to see the result:</p>
<div onmouseover="over()" onmouseout="out()">
<h2> This is inside the division </h2>
</div>
</body>
</html>
Practical Example
<html>
<head>
<title>Mouse Events</title>
</head>
<body>
<h2>Following are the Mouse Events</h2>
<input type="button" name="btn1" onmouseover="alert('You pointed your mouse on
the Button');" value="Hover mouse on me"><br><br>
<input type="button" name="btn2" onmouseout="alert('You pointed your mouse out
of the Button');" value="Hover out of me"><br><br>
<input type="button" name="btn3" onclick="alert('You left-clicked on the Button');"
value="Left-click on me"><br><br>
<input type="button" name="btn4" oncontextmenu="alert('You right-clicked on the
Button');" value="Right-click on me"><br><br>
</body>
</html>
Exercise:
1) Write a program for changing the option list dynamically.
2) Develop a program for as we enter the firstname and lastname , email is
automatically generated.
Marks Obtained Dated Signature of
Teacher
Process Related Product Total
(15) Related (50)
(35)