Forum Moderators: open

Message Too Old, No Replies

Inserting referer page text into form value

Inserting referer page text into form value

         

themoron

2:44 pm on May 29, 2003 (gmt 0)



I don't know if anyone can help me.

I have about 100 products linking to an enquiries form contained within enquiry.html which sends (on submit) the contents via email. I would like the Product name field to be automatically filled in by getting some text from the refering page.

Is this possible to do some how?

I have noticed people asking the same question in the past with no real conclusion.

BlobFisk

2:50 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It most certainly is possible. You can do this using JavaScript by attaching the product name to the url eg: enquiry.html?product=myProduct, and then extracting this on the enquiry page and adding the value to the form object using JavaScript.

Method 2 is to use a server side language. Have your links as form posts that send the product to the enquiry page (via a hidden input) and then on the enquiry page write the value to the form object.

themoron

7:58 pm on May 29, 2003 (gmt 0)



Thanks Blob,

You don't happen to have the javascript code for my enquiry page do you? I have looked around the web and cannot find anything.

Cheers

themoron :@)

themoron

9:30 am on May 30, 2003 (gmt 0)



I am really having trouble with this one, I just cannot find the code on the web, I also need to get that data (once I have it as a variable into the field value, does anyone know how to do that?

Thanks

themoron :@)

tedster

9:48 am on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a tutorial at HTML Goodies [htmlgoodies.com]. That should give you a running start.

themoron

11:39 am on May 30, 2003 (gmt 0)



Thanks, but I am still having problems with it. The tutorial in the link outputs the value to javascript form, whereas my form is an HTML form. Please could someone post the code as I am at a complete loss.

Thanks

themoron :@)

BlobFisk

12:33 pm on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Once you have taken your variable from the URL, you can display it in your form by using document.formName.elementName.value.

themoron

1:24 pm on May 30, 2003 (gmt 0)



Great!

I have done it, it only took two days to sort it out. Well it's a good job I'm not self employed and am payed by the hour!

Thanks you guys

themoron :@)