Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to pass URL of current page to form field on linked to page? Reply To: How to pass URL of current page to form field on linked to page?

#177638
Alen
Participant

We can’t access local files on your computer (link you posted).

Also, if you are using PHP why are you relaying on JavaScript. If I’m understanding you correctly, I would approach it with something like:

Page with Call to Action (let’s call it index.php)


<?php
echo '<a href="form.php?last-page='.$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"].'">Call to Action</a>';
?>

Page with the form (let’s call it form.php)


<input type="hidden" value="<?php echo $_SERVER["QUERY_STRING"]; ?>">

You’ll get this result


<input type="hidden" value="last-page=example.com/index.php">