Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,641 members, 7,809,405 topics. Date: Friday, 26 April 2024 at 09:03 AM

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

Nairaland Forum / Science/Technology / Programming / Javascript Pricing Table Toggle Between 3 States. (798 Views)

HTML-CSS Tutorial: How To Create A Pricing Page With HTML And CSS / Websiteninja.pro : High quality designs without high pricing / After 10days Of Coding With Html, Css And Javascript Forum4africa Is Ready (2) (3) (4)

(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.

1 Like

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)

What Can I Specially Use Lua For? / Is Electronics And Computer Engineering A Good Course In Nigeria / Bootstrap Vs SASS Vs Material UI

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.