I believe we discussed this in private message, but I will post here the steps I took to create a dynamic contact form that contains the clicked image from a gallery.
1. First I added the below code to
Settings > Custom > Custom Javascript, as we will need it to extract url parameters.
function get_param(param){
var query =location.search.substring(1);
var vars = query.split('&');
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split('=');
if(pair[0] == param) return pair[1];
}
return(false);
}
2. For your page
panomagic.eu/PrintShop/ I added the following link to page
settings > gallery > caption > caption defaults > Default Image Link:
/contact/?image={image_path}
The above basically assigns all gallery images as a link, linking to your /contact/ page, and also forwarding ?image path as url parameter by using the dynamic {image_path} variable.
3. Finally, for your
/contact/ page, I added the following code to
settings > page > advanced > page javascript:
var image = get_param('image');
if(!image) return;
var form = document.getElementsByClassName('contactform')[0];
if(!form) return;
form.insertAdjacentHTML('afterbegin', '<a href="' + image + '" data-popup><img src="' + image + '" class="x3-style-frame"></a><input type="text" name="image" value="' + image + '">');
The code basically checks if the
?image parameter is set, and then injects some HTML into the form based on the image parameter value. In this case, I added the image as an <img> tag into the form, as well as an <input> field with the image path, that gets forwarded in the email. The html can easily be adjusted.