1

I am trying to setup a form which grabs the hash from the url, then uses that value to determine what radio inputs to check. The latter part is working, but i cannot get the hash retrieval to work.

var url = document.referrer;
var dec= decodeURIComponent(url.replace(/\+/g, '%20'));
var hash = url.substring(url.indexOf('?')+1);
var hash = decodeURI(hash);

In firefox console, i try 'console.log(hash)', and simply get a Reference Error saying that 'hash is not defined'.

The entire script is here if needed - http://pastebin.com/Yq9NbHyz

Jake6192
  • 13
  • 5

1 Answers1

0

Because hash is not global variable. Use window.location.hash or location.hash

Justinas
  • 41,402
  • 5
  • 66
  • 96
  • If you meant adding it in the if statement, then it solved the reference error, but it is still saying that 'hash' is undefined. Why would this be? – Jake6192 Jan 06 '17 at 09:24