Hide Image | WordPress.org

[ad_1]

Hello,

I’m not sure about your question. But if you want to insert images on your form and display them based on the choices selected from a dropdown field, you have multiple alternatives:

  • You can insert multiple “Media” controls, one per image, and configure them as dependent fields on the DropDown choices.

Learn more about dependencies by reading the following blog post:

https://cff.dwbooster.com/blog/2020/03/01/dependencies

  • Alternatively, you can display the images by code. I’ll try to describe the process with a hypothetical example.

Assuming the dropdown field is the fieldname1, with choices A, B, and C. If the user selects choice A, you want to display the image , display the image when the user selects choice B, and for the choice C.

First, insert an “HTML Content” field in the form, and enter a DIV field in its content where displaying the images. Ex <div class="images-container"></div>

Second, insert a calculated field, that you can configure as hidden by ticking a checkbox in its settings, and enter the following equation:

(function(){
var image="";
if(fieldname1 == 'A') image="<img src="https://www.yourwebsite.com/images-path/image1.png">";

if(fieldname1 == 'B') image="<img src="https://www.yourwebsite.com/images-path/image2.png">";

if(fieldname1 == 'C') image="<img src="https://www.yourwebsite.com/images-path/image3.png">";

jQuery('.images-container').html(image);
})()

Best regards.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer