penders - 1:41 pm on Jan 17, 2012 (gmt 0)
You define a global variable exactly as you have done, outside of any functions.
However, the problem with your script is that you are assigning the INPUT control to your global variable before the INPUT control has actually been defined in the document (before it is part of the DOM). So it is 'undefined'.
You need to assign the INPUT control to your global variable after it has been defined. Either in the onload event or some point after it in the markup...
<form name="myForm" method="get" onsubmit="return false;" action="">
<input name="myInput" value="Hello world!" onfocus="getFocus();" onblur="loseFocus();"><br>
<input type="button" onclick="displayResult();" value="Display input value">
var x = document.myForm.myInput;