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.
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 <?php echo "<script>document.writeln(h1function);</script>"; ?>
, but it's not working correctly.
Here's the js script:
function h1function(){
var h1 = document.getElementsByClassName("entry-title");
for(var i = 0; i < h1.length; i++){
alert(h1[i].innerHTML);
}
}
1st page:
<a href="http://example.com/list/summary/" target="_blank" onclick="h1function()">
HTML (2nd page):
<input type="text" name="h1title" value="<?php echo "<script>document.writeln(getJob);</script>"; ?>" size="40" id="h1title" required/>