<!-- JavaScript:DOM code snippet 6. -->
<!-- Reference and gain access to a node or element directly
with dot and array notation. -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
<script language="JavaScript" type="text/javascript">
/* accessing individual form elements, controls or fields */
function highlightValue(){
	/* access the first form in the document and its second field */
	var e = document.forms[0].elements[1]
	/* highlight the second field */
	e.style.backgroundColor="#0000FF"
		}
</script>
</head>

<body>
<!-- this is the first form in the document -->
<form name="frmOrder" id="frmOrder">
<p>Product:</p><input type="text" name="txtProduct" size="50" value="Potatoes" /><br />
<p>Order size:</p><input type="text" name="txtOrder" size="50" value="500" /><br />
<p>Cost:</p><input type="text" name="txtCost" size="50" value="100" /><br />
</form>
<br />

<!-- this is the second form in the document -->
<form name="highlightForm" id="highlightForm">
<!-- calls function when button is clicked -->
<input type="button" value="Highlight the second field of the above form" onclick="highlightValue()" />
</form>

</body>
</html>