global and local javascript scope
Why is it that the global variable is not recognized in this function?

    <script type="text/javascript">
    var id_f = document.getElementById('f');

    function foo()
    {
    id_f.innerHTML=("text");
    }
    </script>
global and local javascript scope
===

Why is it that the global variable is not recognized in this function?

    <script type="text/javascript">
    var id_f = document.getElementById('f');

    function foo()
    {
    id_f.innerHTML=("text");
    }
    </script>