I have a form created using Caldera Forms on my Wordpress website. It's a multipage form with 1 question on each page. Answers to the questions are either yes or no. I have 12 images. What I want to do is that on each question check if the answer is "yes" and then display the corresponding image beneath the form (or on another page).
I am having a really hard time understanding in how do I write my custom javascript to handle the callback of the submit of my form and then append my images to the body of my wordpress page.
I am a beginner in wordpress and I am only aware of manipulating plugins and themes through the UI and not through code. I have a sound experience in CSS and JS so I know how would've done this in a non-wordpress(custom built website).
I want to know where I can write my custom Javascript code to achieve my objective of showing images or is there any other way I can do it?
Thanks.
You can make alterations dependent on form submission by checking if the form or a certain input has been submitted. You can do this in multiple ways
REQUEST_METHOD
server variableif ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Show images here
}
isset()
if (isset($_POST['submit'])) {
// Your content here
}
When working with html I personally find it better to use it like this:
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST'): ?>
<img src="some-picture.png" />
<?php endif; ?>