ui: Fix repeat offer selected coins.

This commit is contained in:
tecnovert
2023-07-29 15:30:41 +02:00
parent 55ded71686
commit 547e50acb6
2 changed files with 67 additions and 11 deletions

View File

@@ -12,17 +12,21 @@ function setupCustomSelect(select) {
}
});
// Set the selected option based on the stored value
const storedValue = localStorage.getItem(select.name);
if (storedValue) {
const selectedOption = select.querySelector(`option[value="${storedValue}"]`);
if (selectedOption) {
if (select.value == '-1') {
// Set the selected option based on the stored value
const storedValue = localStorage.getItem(select.name);
if (storedValue) {
select.value = storedValue;
const image = selectedOption.getAttribute('data-image');
if (image) {
select.style.backgroundImage = `url(${image})`;
selectImage.src = image;
}
}
}
// Set the selected option image based on the selected value
const selectedOption = select.querySelector(`option[value="${select.value}"]`);
if (selectedOption) {
const image = selectedOption.getAttribute('data-image');
if (image) {
select.style.backgroundImage = `url(${image})`;
selectImage.src = image;
}
}