View Full Version : pre-filled subject heading in contact form
johnshackleton
26-Jan-2006, 03:47 PM
I want to create a button for each product which generates a separate pop-up containing the contact us form.
I think I should be able to edit the Act_ContactUs template and add extra fields etc.
What I really need is the Subject heading to be pre-filled with the name of the Product that it has been clicked from.
Thanks in advance.
John
Kermy
26-Jan-2006, 05:48 PM
Make the button link to the contact form, but add the product name to the end of the URL lke this:
<a href="contactform.html?p=NETQUOTEVAR:PRODUCTTITLE"><img src="button.gif" /></a>
Then, in the contact form page, add an ID tag of "subject" to the Subject text box, something like this:
<input type="text" name="subject" id="subject" />
Finally, add this code directly underneath the input box:
<script type="text/javascript">
if ((location.href).match("p=")){
document.getElementById("subject").value=(location.href).substring((location.href).lastIndexOf("=")+1,(location.href).length);
}
</script>
This will set the Subject box to the product name, but won't display anything when the page is linked to normally.
(I think NETQUOTEVAR:PRODUCTTITLE should get the product name, I'm not at work so I can't check the variable name).
cdicken
27-Jan-2006, 08:17 AM
Neat solution! Nice one.
Just for future reference, the variable you need to use is NETQUOTEVAR:PRODUCTNAME
Kermy
27-Jan-2006, 10:00 AM
Thanks for claryfying that one, Chris.
Something else that I hadn't thought of was dealing with spaces in the product name. So this this code instead:
<script type="text/javascript">
if ((location.href).match("p=")){
document.getElementById("subject").value=decodeURI((location.href).substring((location.href).lastIndexOf("=")+1,(location.href).length));
}
</script>
impos
15-May-2006, 07:41 AM
Where does the: 'Just for future reference, the variable you need to use is NETQUOTEVAR:PRODUCTNAME' come in?.
I am unable to use this form so would be grateful if anyone could help with the correct information
Thanks
Andrew
Kermy
15-May-2006, 08:55 AM
Chris was correcting my advice in my first reply. If you do the following, you should get it working:
Make the button in the product template link to the contact form, but add the product name to the end of the URL lke this:
<a href="contactform.html?p=NETQUOTEVAR:PRODUCTNAME"><img src="button.gif" /></a>
Then, in the contact form page, add an ID tag of "subject" to the Subject text box, something like this:
<input type="text" name="subject" id="subject" />
Finally, add this code directly underneath the input box:
<script type="text/javascript">
if ((location.href).match("p=")){
document.getElementById("subject").value=decodeURI((location.href).substring((location.href).lastIndexOf("=")+1,(location.href).length));
}
</script>
NormanRouxel
31-May-2007, 12:21 PM
This (untested) idea may be of use too ( http://community.actinic.com/showpost.php?p=165936&postcount=3 ). It was for someone wanting to pass the product name to an email a friend popup.
It's a V8 post, but would be easy to amend for V7.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.