Loading
View RSS Feed

Angad Kumar Shukla's blog

Event Handling In JavaScript - OnChange, OnClick, OnDouble Click, OnKey Press

Rating: 2 votes, 5.00 average.
OnChange :

on change 2.bmp

on change 1.bmp

on change 3.bmp

Code:
<html>
	<head>
	<script type="text/javascript">
	var f,phone,i;
	function phoneno(f)
	{
		arr=new Array("","9874550812","9883656660","9474811813",
			"9883656651","9432965506","9674411805","9433307283");
		n=f.dropbox.selectedIndex;
		f.phone.value=arr[n];
	}
						
	</script>
			
	</head>
	
	<body bgcolor="#B8BA23" text="red">
	<center>--------HERE YOU FIND YOUR PHONE DIRECTORY--------
	<form nanme="my form">
	<select name="dropbox" onchange="phoneno(this.form)">
	<option>select</option>
	<option>prosanta</option>
	<option>tarun</option>
	<option>jaydeep</option>
	<option>ravi</option>
	<option>alam</option>
	<option>saurav</option>
	<option>poly ma'am</option>
	</select>
	<br>
	<br>
	<br>
	phone no::     <input type="text" name="phone"></center>
	</form>
	</body>
</html>
OnClick


on click event after clicking.bmp

onclick event before clicking.bmp

Code:
<html>
<head>
	<script type="text/javascript">
	function show_alert()
	{	
		alert("You press one click on your screen!!");
	}
	</script>
</head>
<body bgcolor="blue">
<input type="button" onClick="show_alert()" value="show alert box"/>
</body>
</html>


OnDouble Click


on double click after clicking.bmp

on double click before clicking.bmp


Code:
<html>
<head>
	<script type="text/javascript">
	function welcome()
	{	
		alert("You Must double click on screen... ");
	}
	</script>
</head>
<body bgcolor="magenta" OnDblClick="welcome()">
</body>
</html>
OnKey Press

onkey press event after pressing.bmponkey press event before clicking.bmp
Code:
<html>
<head>
	<script type="text/javascript">
	function welcome()
	{	
		alert("welcome to i.t.")
	}
	</script>
</head>
<body onKeypress="welcome()">

</body>
</html>




Please follow the above link for rest of other events.

Submit "Event Handling In JavaScript - OnChange, OnClick, OnDouble Click, OnKey Press" to Digg Submit "Event Handling In JavaScript - OnChange, OnClick, OnDouble Click, OnKey Press" to del.icio.us Submit "Event Handling In JavaScript - OnChange, OnClick, OnDouble Click, OnKey Press" to StumbleUpon Submit "Event Handling In JavaScript - OnChange, OnClick, OnDouble Click, OnKey Press" to Google

Updated 12-04-2011 at 06:38 PM by Harsh

Categories
Web Design

Comments




Disclaimer: Users of techforum4u.com are responsible for ensuring that any material they post (article, blog posts, images or other mulitimedia content) does not violate or infringe upon the copyright, patent, trademark, or any personal or proprietary rights of any third party, and is posted with the permission of the owner of such rights.Anyone who violates these rules may have their access privileges removed without warning.