Fetch (json)
fetch("php-sql-file.php") //
.then((response) => { return response.json() }) //
.then((data) => {
const select_element = document.getElementById("select-element-id");
for(let i = 0; i < data.length; i++) {
option_element = document.createElement("option"); // create option element
option_element.value = data[i].<column-index>; // get the named index from the results, set the options value
option_element.id = data[i].<column-index>; // get the named index from the results, set the options id
option_element.innerHTML = data[i].<column-index>; // get the named index from the results, set the options text
select_element.add(option_element); // add the option element to the select element
}
//console.log(data); // log to the console
})
.catch((error) => {
console.log(error);
});