₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,117 members, 8,420,441 topics. Date: Thursday, 04 June 2026 at 07:46 PM

Toggle theme

Javascript Pricing Table Toggle Between 3 States. - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingJavascript Pricing Table Toggle Between 3 States. (889 Views)

1 Reply (Go Down)

Javascript Pricing Table Toggle Between 3 States. by Nobody: 10:05am On Apr 29, 2020
Just like the title, I'm trying to achieve a result like the screenshot attached, I'm trying to get this to work with 3 pricing layouts, so on click the 7 days trial hide div 2 and 3, it's supposed to be easy but for some reason, I can't figure it out. Guess I need to go back and learn the basics from scratch angry Any help is greatly appreciated. Thanks.

Code for 2 toggle states I want rewritten to work with 3 states:

<script type="text/javascript">
// toggle frequency

function toggleFrequency() {
var yearlyElement = document.getElementById("yearlyPlans"wink;
var monthlyElement = document.getElementById("monthlyPlans"wink;
if (yearlyElement.style.display === "none"wink {
yearlyElement.style.display = "block";
monthlyElement.style.display = "none";
} else {
yearlyElement.style.display = "none";
monthlyElement.style.display = "block";
}
}

window.onload = function () {
document.getElementById("yearlyPlans"wink.style.display = "none";
document.getElementById("dropDownMenuMonthly"wink.style.display = "none";
};

window.addEventListener("click", function (e) {
if (document.getElementById("dropdownMonthly"wink.contains(e.target)) {
document.getElementById("dropDownMenuMonthly"wink.style.display =
"block";
} else {
document.getElementById("dropDownMenuMonthly"wink.style.display = "none";
}
});

window.addEventListener("click", function (e) {
if (document.getElementById("dropdownYearly"wink.contains(e.target)) {
document.getElementById("dropDownMenuYearly"wink.style.display = "block";
} else {
document.getElementById("dropDownMenuYearly"wink.style.display = "none";
}
});

// toggle dropDown

function toggleMenu() {
var monthlyDropdown = document.getElementById("dropDownMenuMonthly"wink;
var yearlyDropdown = document.getElementById("dropDownMenuYearly"wink;
if (monthlyDropdown.style.display == "none"wink {
monthlyDropdown.style.display = "block";
yearlyDropdown.style.display = "none";
} else {
monthlyDropdown.style.display = "none";
yearlyDropdown.style.display = "block";
}
}
</script>

Re: Javascript Pricing Table Toggle Between 3 States. by Karleb(m): 10:41am On Apr 29, 2020
Re: Javascript Pricing Table Toggle Between 3 States. by Nobody: 4:23am On Apr 30, 2020
Karleb:
You need to understand Tabs.

https://www.w3schools.com/howto/howto_js_tabs.asp
Not what I wanted but I got it to work by passing onclick function to hide or show divs depending on the ul id clicked. I don't know if it's the right way to do it, but I got no syntax errors and it works just fine. grin Thanks for your help.
Re: Javascript Pricing Table Toggle Between 3 States. by Icharityteam(m): 12:36pm On Jun 12, 2020
gross Intel. I beg you in the name of God I have been trying to reach you. please Whatsapp me on 07025261602. or drop your whatsapp. please. I have a life threatening issue
1 Reply

How To Create A Dark Mode Toggle With CSS & JavascriptHow To Create A Responsive Pricing Table With HTML & CSS (in 2 Minutes!)Mobile Technology: Lets Build A Mobile App With Javascript234

Why Python Is Considered The Top Programming Language Ahead Of Javascript And C+ALX Colleague In Enugu....Unleash Playwright On Replit - Python Web Automation Made Easy!