Articles → JavaScript → document.getElementByID in JavaScript

document.getElementByID in JavaScript








Assigning id to control in HTML




<input type="text" id="txtName">



What is document.getElementById





Example




<html>
<head>
	<script language="javascript" type="text/javascript">
		function ClickMe()
		{
			alert(document.getElementById("txtName").value);
		}
	</script>
</head>
<body>
<form method="post" action="GetElementByIDPage.html">
	<input type="text" id="txtName">
	<input type="button" value="click" onclick="javascript:ClickMe();">
</form>
</body>
</html>





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, December 31, 2010

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250