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?
here's my code:
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
myvar = getURLParameter('searchbox');
document.getElementById('field').value = myvar;
I keep on receiving a "Uncaught TypeError: Cannot set property 'value' of null" in the last line at document.getElementById('field').value = myvar;
Why? where I'm getting wrong?