I want get img path from my database in my script
const modalSelect = document.querySelector('#modal-select')
const list = document.querySelectorAll('#modal-option')
modalSelect.addEventListener('change', function(e) {
const option = modalSelect.options[modalSelect.selectedIndex].text
const imgOpt= '{{ $products->where('name', 'option')->get('image') }}'
list.forEach((element, i) => {
const valueList = element.value
if (valueList == option) {
Swal.fire({
title: option[0].toUpperCase() + option.slice(1),
text: "Modal with a custom image.",
imageUrl: "imgOpt",
imageWidth: 400,
imageHeight: 200,
imageAlt: option + " image"
});
}
});
})
I tried searching for data with where and mix with const option in my script, but it didn’t work, I don’t know how to combine it