plugin development – how to add contact form 7 shortcode in javascript variable

Question

In Contact Form 7 I have created a dropdown with 3 options under it “Dallas” “Houston” “Austin” . I wrote this js code so that if I select Dallas then “Houston” “Austin” will hide. The rest of the options will work in the same way. But I am not able to insert the dropdown’s shortcode

Here is the shortcode of my dropdown:- [condition]

I create this

    <div id="dallas"><h1>Dallas city</h1></div>
<div id="houston"><h1>Houston City</h1></div>
<div id="austin"><h1>Austin City</h1></div>


<script>
    const paragraphText = "dallas"; 

const dallasDiv = document.getElementById(“dallas”);
const houstonDiv = document.getElementById(“houston”);
const austinDiv = document.getElementById(“austin”);

if (paragraphText === “dallas”) {
dallasDiv.style.display = “block”;
houstonDiv.style.display = “none”;
austinDiv.style.display = “none”;
sanantonioDiv.style.display = “none”;
atlantaDiv.style.display = “none”;
} else if (paragraphText === “houston”) {
dallasDiv.style.display = “none”;
houstonDiv.style.display = “block”;
austinDiv.style.display = “none”;
sanantonioDiv.style.display = “none”;
atlantaDiv.style.display = “none”;
} else if (paragraphText === “austin”){
dallasDiv.style.display = “none”;
houstonDiv.style.display = “none”;
austinDiv.style.display = “block”;
sanantonioDiv.style.display = “none”;
atlantaDiv.style.display = “none”;
}

</script>

0
MD. RABIUL ISLAM 4 weeks 2023-05-04T22:07:20-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse