title: How to pass values from one HTML page to other using java script?
body: <p>I want to pass my value of one variable to another html page using query string.  </p>
  
  <p><strong>first.html:</strong></p>
  
  <pre><code>&lt;body &gt;
     &lt;form id="form1" name="form1" action="2.html"&gt;
     &lt;input type="text" name="txtFileName" id="txtFileName"/&gt;
  
     &lt;input type="hidden" name="hid1" value=""&gt;
     &lt;br&gt;&lt;input type="submit"  value="Send me your name!"  onClick="submitform();"&gt;
     &lt;br&gt;
     &lt;/form&gt;
     &lt;script type="text/javascript"&gt;
     function submitform()
     {
       document.form1.hid1.value="hidden value";
  
      document.form1.submit();
     }
  &lt;/script&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p><strong>second.html:</strong>  </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;SCRIPT LANGUAGE="javascript"&gt;
  function getQueryVariable2(variable) { 
  
    var query = window.location.search.substring(1); 
    document.write(query);
    var vars = query.split("&amp;"); 
    document.write("&lt;br /&gt;");
    document.write(vars);
  
    for (var i=0;i&lt;vars.length;i++) { 
      var pair = vars[i].split("="); 
      if (pair[0] == variable) { 
        return pair[1]; 
      }
    } 
  } 
  
  
  
  &lt;/SCRIPT&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Good morning&lt;/h1&gt;
  &lt;script LANGUAGE="javascript"&gt;
  document.write("&lt;br /&gt;txtFileName = " + getQueryVariable2("txtFileName"));
  document.write("&lt;br /&gt;hid1 = " + getQueryVariable2("hid1"));
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you suggested I created my pages. Still these are working the desired operation. What is my error?</p>