title: Why I get " Uncaught TypeError: Cannot set property 'value' of null"?
body: <p>I'm new to develope in javascript, I'm sure this is a banal question and probably it has a very simple answer but I'm stuck and it seems I can't figure it out in any way. Can anyone give me an explaination on this?</p>
  
  <p>here's my code:</p>
  
  <pre><code>    function getURLParameter(name) {
        return decodeURIComponent((new RegExp('[?|&amp;]' + name + '=' + '([^&amp;;]+?)(&amp;|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
      }
      myvar = getURLParameter('searchbox');
      document.getElementById('field').value = myvar;
  </code></pre>
  
  <p>I keep on receiving a "Uncaught TypeError: Cannot set property 'value' of null" in the last line at document.getElementById('field').value = myvar;</p>
  
  <p>Why? where I'm getting wrong?</p>