title: Passing a variable to other page and execute a if condition function
body: <p>I have a javascript function that is passing the value of a variable to other page, after a button is clicked.
  It seams to pass the value partialy but something is wrong as my conditional compare function isnt working. </p>
  
  <p>First page:</p>
  
  <pre><code>&lt;a href="javascript:void(0)" onclick="pass(2)"&gt;&lt;/a&gt;
  &lt;script&gt;
  function pass(x){
          var somval = x;
          window.location = 'contact/index.php?somval=' + somval;
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Second page:</p>
  
  <pre><code>&lt;script&gt;
  var somval;
      var qsParm = new Array();
      function qs() {
      var query = window.location.search.substring(1);
      var parms = query.split('&amp;');
      for (var i=0; i &lt; parms.length; i++) {
          var pos = parms[i].indexOf('=');
          if (pos &gt; 0) {
              var key = parms[i].substring(0, pos);
              var val = parms[i].substring(pos + 1);
              qsParm[key] = val;
          }
      }
      }
  
      function compare(){
          if(somval == 1){
              alert(1);
              $("#radio_1").prop("checked", true);
          }else if(somval == 2){
              alert(2);
              $("#radio_2").prop("checked", true);
          }else{
          };
      }
      compare();
  &lt;/script&gt;
  </code></pre>
  
  <p>The only error displayed on console is: undefined index.php?somval=1:352</p>