I am currently querying data (with an api call) into a select list and creates a dropdown list. It renders the data however, I want a default value of "--Make a Selection--". I tried adding an option tag but gets overridden by the post query. Any ideas/solutions that my fix my issue?
<body onload="getPatients()">
<div id="message"></div>
<p class="title">Select a patient</p>
<select name="patients" id="patientList" required>
<option selected>--Make a Selection--</option>
</select>
I tried adding an option tag within the select to make it the default but as I stated earlier, the dropdown post query overrides the option tag.
Any help would be appreciated. Thank you.
The following is the getPatients call.
async function getPatients() {
console.log("all good");
var patientEl = document.getElementById("patientList");
console.log("still good");
//first fetch all of the patients from the patients table.
let patientReq = await fetch("https://api.quickbase.com/v1/records/query",
{
method: 'POST',
headers: headers,
body: jbody
}).catch(err =>{console.log(err)});
let jsonpatients = await patientReq.json();
//console.log(patients);
//Ok now we have all the patients from the application.
//now take your json response and put it into your render function
renderPatients(jsonpatients);
}