Hello,
I am reading some JS book and basically there is this code that inputs some text into a text box using getElementById, and i have that script as an external file, but if it is placed above the form, for example in the head section, it doesn't work, but if it is placed after the form it works. Why is that ?
html form:
js code:HTML Code:<body> <a href="ssfsf.html" id="msg_link">Get Message</a> <br /><br /> <form> <input type="text" id="msg_box" /> </form> <script language="javascript" src="functions.js"></script> </body> </body>
thanks!Code:var message_text = 'Help! Im in a box!'; var message_link = document.getElementById("msg_link"); var message_box = document.getElementById("msg_box"); message_link.onmouseover = function() { message_box.value = message_text; } message_link.onmouseout = function() { message_box.value = ''; }






Bookmarks