Sending Variable content, not Variable name

I

Ian Hubling

Here's what I'm trying to do:

I have a large number of pages that call a pop-up survey page. It is
important to know what page the survey is referring to - so I am
passing the name of the referring page through the URL.

The problem I'm having is that when the data on the survey page is
submitted through formmail, I can't seem to get the referring page's
name sent too - I keep getting the variable name itself, not the
contents of the variable.

So for instance, if the referring page is 123.htm, and I assign it to
variable "external_url", I get the name "external_url" sent through
formmail, not the contents of the variable.

HELP.

Here's the script I'm using to on the popup survey page (or at least
the part to parse out the referring page's name).

<Script LANGUAGE="javascript">
external_url = window.location.search.substring(1);
</script>

Amongst my input fields for formmail I presume I would include:

<input type="hidden" name="subject" value="external_url">

But this doesn't work.

I haven't bothered to include the rest of the form code - but it is
working fine (ie I get the mail results back, its just that "subject"
comes back as "external_url" instead of the referring page's name.

Also, I know that "external_url" is working because I have a
document.write(external_url); in the document to ensure that the
variable is working and containing the correct info displayed on the
screen.

I figure this is a simple issue - but I can't figure it out. Thanks
in advance.
 
M

Matt Kruse

Ian Hubling said:
<Script LANGUAGE="javascript">
external_url = window.location.search.substring(1);
</script>
Amongst my input fields for formmail I presume I would include:
<input type="hidden" name="subject" value="external_url">

You can't just include variable names and expect javascript to interpret
them. Instead, you should have javascript write out the hidden input itself,
like this:

document.write('<input type="hidden" name="subject" value="' + external_url
+ '">');

Your document will then contain a hdiden input with the correct value.
 
I

Ian Hubling

Thanks a million Matt - I had to play around with it - but I understood
what you were saying and managed to get it to work.

This will save a lot of work and coding in the long run. Again - thanks
for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top