Fix selected server value

This commit is contained in:
30hours 2024-02-04 11:05:45 +00:00
parent 969c031ca2
commit 0e3b746e2f

View file

@ -10,10 +10,12 @@ function toggle_button(button) {
} else { } else {
button.classList.add("btn-secondary"); button.classList.add("btn-secondary");
button.classList.remove("btn-success"); button.classList.remove("btn-success");
}
// Set the value to server.url when the button is pressed // Remove the corresponding hidden input when the button is deselected
var serverUrl = button.getAttribute('value'); var serverUrl = button.getAttribute('value');
button.value = pressed === 'true' ? serverUrl : ''; var hiddenInputs = document.querySelectorAll('input[name="url"][value="' + serverUrl + '"]');
console.log(button.value); hiddenInputs.forEach(function (input) {
} input.parentNode.removeChild(input);
});
}
}