I am trying to create an onclick event that updates the values of a bootstrap modal element with results from a MySQL ajax query:
function UpdateModal($id){
document.getElementById("modal_id").value=$id;
}
$results = GetMySQLResults();
button.onclick = function(){
UpdateModal($results[0]["id"]);
}
However the problem is it always says "$result" is undefined when I click the button.
Is there a way to solve this without me having to dynamically create a modal?