How to pass the js variable to another page
<p>I have 2 pages. The first page has a Javascript function that gets the value of h1 and when the user click the button, the alert will be displayed with the value of h1 and it will redirect to another page. The 2nd page have an HTML form.</p>

<p>Now I want to call the js function from the 1st page and display the value in the input text (2nd page).
I tried this <code>&lt;?php echo "&lt;script&gt;document.writeln(h1function);&lt;/script&gt;"; ?&gt;</code>, but it's not working correctly.</p>

<p>Here's the js script:</p>

<pre><code>function h1function(){
    var h1 = document.getElementsByClassName("entry-title");
        for(var i = 0; i &lt; h1.length; i++){
            alert(h1[i].innerHTML);
    }
}
</code></pre>

<p>1st page:</p>

<pre><code>&lt;a href="http://example.com/list/summary/" target="_blank" onclick="h1function()"&gt;
</code></pre>

<p>HTML (2nd page):</p>

<pre><code>&lt;input type="text" name="h1title" value="&lt;?php echo "&lt;script&gt;document.writeln(getJob);&lt;/script&gt;"; ?&gt;" size="40" id="h1title" required/&gt;
</code></pre>