SandraNanou Posted September 25, 2019 Share Posted September 25, 2019 (edited) Hi, I'd like to add a link to the contact form page with the subject pre selected in the select form. For example, I have 3 different subjects in my contact form : 1- Webmaster 2-Customer service 3-Ask for a quote I'd like to add a link to the contact form with "2-Customer service" selected. Something like : http://my-site.com/index.php?controller=contact#id_contact=2 How could I do this? Thank you!! Edited September 25, 2019 by SandraNanou (see edit history) Link to comment Share on other sites More sharing options...
SandraNanou Posted September 25, 2019 Author Share Posted September 25, 2019 For those who are interested, here is the solution : Page product (or other) with the link : <a class="btn btn-block btn-secondary" href="{$link->getPageLink('contact', true)|escape:'html':'UTF-8'}?id=3" title="{l s='Ask for a quote' d='Shop.Theme.Catalog'}">{l s='Ask for a quote' d='Shop.Theme.Catalog'}</a> Contactform.tpl - add ID to options : <select name="id_contact" id="id_contact" class="form-control form-control-select" onchange="showElemFromSelect('id_contact', 'desc_contact')"> {foreach from=$contact.contacts item=contact_elt} <option id="{$contact_elt.id_contact}" value="{$contact_elt.id_contact}">{$contact_elt.name}</option> {/foreach} </select> Custom.js : function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } var optionId = getParameterByName('id'); $('#id_contact option#' + optionId).attr("selected","selected");} Regards Link to comment Share on other sites More sharing options...
KIMW Posted September 21, 2022 Share Posted September 21, 2022 Hey, I can't get the code working for PS 1.7.8.2. Do I have to make any changes for our version? Thanks in advance! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now