Carrying data from product button to a field in contact form


Completely unsure of the true category this belongs in.

Working on a website which has product categories, and then lists between 10-20 products per category. Each product has two buttons, ‘More Information’ which displays a datasheet for relevant product, and ‘Make an Enquiry’ which I somehow hope can work in the following way.

Customer clicks ‘Make an Enquiry’ on a certain product.
Customer is redirected to contact.html page.
The contact form displays the chosen products name in a field.
Customer proceeds to complete form fields and submit.

I am looking for guidance, I have tried researching this but unless I’m asking the wrong thing I can’t find anything relevant to what I’m trying to do.

My current thought is on the ‘Make an Enquiry’ button I use the href=“contact.html/#product-name” and use a hash, and somehow get it to display this way?

Please help save a man on a deadline :smiley:

I suggest you use something like this for your contact page:

<label>Product:<input type="text" id="product" disabled></label>
document.getElementById("product").value=location.hash.substr(1).replace(/\+/g," ");

Note substr(1) removes the # character.

The standard way would be to use a query string in the URL, Eg:-


Where the ? says you are about to enter a query string. product is the parameter and name is the value of the parameter (product name or ID).
If you have this you can then “get” the parameter value with a GET request and use it in the HTML. Exactly how you do that is another matter.

This would lead me to assume the site has some kind of back-end programming going on and likely a database, possibly a CMS.
If so, do you know which those are?

Hi Sam,

No, as the ‘product’ pages are purely .pdf datasheets and I hate working on crowded CMS’s I figured that I’d build this from the ground up.

Still 90% unsure how to actually figure topic out, but as far as the back-end goes, it doesn’t have one, no db to work with…

OK, with a back-end, such as PHP (which is common) you would $_GET['product'], the you could echo the string (escaped) into the input value parameter.

But since you have no back-end, I guess you will have to do this on the client side, probably with javascript.

But that aside, it begs the question of how you intend to process the submitted form data with no back-end.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.