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?

#177632
Matt
Participant

Thank you Soronbe, that is very helpful.

It appears that code passes in the URL of the current page the form is on. I want to pass in the URL of the page that links to the page which the form is on.

I have a link to the form page on multiple pages of the site. When a user clicks on one the links, I want to pass the URL of the page the user is on when they click the link to the page with form.

Edit 1: I already have the parameter being passed through which PHP. How can I read the value of the last-page parameter from the JS code?

Here’s an example URL: http://localhost/cc/company/request-demo/?last-page=http://localhost/cc/

Edit 2: I think I may have found it:
var last_page = getUrlVars()["last-page"];

Edit 3: I think I’m closer! I am using the following code but it’s not quite working. It’s giving me a Syntax Error: Unexpected token ILLEGAL

<script type="text/javascript">
document.form[0].00N9000000ApJSm.value = "<?php echo $last-page; ?>";
</script>