From 58901e8d7eee705a978c6dc77a2b67a6a818b432 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sat, 9 Sep 2023 22:52:50 +0200 Subject: [PATCH] Toggle form --- public/bmarket.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/public/bmarket.js b/public/bmarket.js index b825ae4..a92b4b8 100644 --- a/public/bmarket.js +++ b/public/bmarket.js @@ -29,23 +29,34 @@ function resetInputs() { noCostDisplay.value = undefined } -function showYesForm() { +function toggleYesForm() { resetInputs() - yesOrderBtn.classList.add("selected") - yesForm.style.display = "grid" + if (yesOrderBtn.classList.contains("selected")) { + yesOrderBtn.classList.remove("selected") + yesForm.style.display = "none" + } + else { + yesOrderBtn.classList.add("selected") + yesForm.style.display = "grid" + } noOrderBtn.classList.remove("selected") noForm.style.display = "none" } -yesOrderBtn.onclick = showYesForm +yesOrderBtn.onclick = toggleYesForm -function showNoForm() { +function toggleNoForm() { resetInputs() - noOrderBtn.classList.add("selected") - noForm.style.display = "grid" + if (noOrderBtn.classList.contains("selected")) { + noOrderBtn.classList.remove("selected") + noForm.style.display = "none" + } else { + noOrderBtn.classList.add("selected") + noForm.style.display = "grid" + } yesOrderBtn.classList.remove("selected") yesForm.style.display = "none" } -noOrderBtn.onclick = showNoForm +noOrderBtn.onclick = toggleNoForm function showBuyForm() { resetInputs()