We'll leave the body tag alone:

Originally Posted by
joesstlouis
Is there any way to run the function from the body tag instead of inside the select box tags?
Code:
<doctype html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
(function( m, s )
{
function ih( obj, evt, func )
{
obj.attachEvent ? obj.attachEvent( 'on'+evt, func ) : obj.addEventListener( evt, func, false );
}
function f()
{
var slaveBox = document.getElementById( s );
ih( document.getElementById( m ), 'change', function( elem )
{
slaveBox.value = ( elem.srcElement || elem.target).value;
} );
}
ih( window, 'load', f );
})( "selectBox1", "selectBox2" );
</script>
</head>
<body>
<select id="selectBox1" >
<option value="1">Option #1</option>
<option value="2">Option #2</option>
</select>
<select id="selectBox2">
<option value="1">Option #1</option>
<option value="2">Option #2</option>
</select>
</body>
</html>
Bookmarks