From 0e3b746e2f73aab93c3c0dd6bb3948f3c947635b Mon Sep 17 00:00:00 2001 From: 30hours Date: Sun, 4 Feb 2024 11:05:45 +0000 Subject: [PATCH] Fix selected server value --- src/public/js/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/public/js/index.js b/src/public/js/index.js index 8563b32..bb845e4 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -10,10 +10,12 @@ function toggle_button(button) { } else { button.classList.add("btn-secondary"); button.classList.remove("btn-success"); - } - // Set the value to server.url when the button is pressed - var serverUrl = button.getAttribute('value'); - button.value = pressed === 'true' ? serverUrl : ''; - console.log(button.value); -} + // Remove the corresponding hidden input when the button is deselected + var serverUrl = button.getAttribute('value'); + var hiddenInputs = document.querySelectorAll('input[name="url"][value="' + serverUrl + '"]'); + hiddenInputs.forEach(function (input) { + input.parentNode.removeChild(input); + }); + } +} \ No newline at end of file