Jump to content
  • 0

Allow User To Control Image Downloads



The code below was given by CoopperBackPack and it's working really well and I was very grateful for his help. I'd like to go one step further by giving the user the option to make the image download or not by including a Virtual field (Type is Checked and the default is False) so that if the checkbox is ticked the Image will be downloaded and if it's unchecked the download will not happen. I've tried amending the footer code to execute the download if it's checked. The new line is in bold and underlined:

document.addEventListener('DataPageReady', function (event) {
document.querySelector('input[id*="cbParamVirtual12"]').addEventListener("change", imageHandler); 
if(document.querySelector("input[name*="cbParamVirtual13"]").checked == true){

      function imageHandler(event) {
          let calcField = event.target.value;
          document.querySelector("#item-img").src= calcField;

          document.removeEventListener('DataPageReady', imageHandler);

I've also tried the line in the HTML block but I just can't get it to work. The HTML Block code is below

HTML Block:
<img id="item-img" width="680px" </img>

Could someone please help?

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...