const hospitals = [
{ name: "Kenyatta National Hospital", location: "Nairobi", address: "Hospital Rd, Nairobi" },
{ name: "Moi Teaching and Referral Hospital", location: "Eldoret", address: "Nandi Rd, Eldoret" },
{ name: "Aga Khan University Hospital", location: "Nairobi", address: "3rd Parklands Ave, Nairobi" },
{ name: "Coast General Hospital", location: "Mombasa", address: "Kizingo, Mombasa" }
// Add more hospitals here
];
function searchHospitals() {
const input = document.getElementById('location-input').value.trim().toLowerCase();
const resultsDiv = document.getElementById('results');
if (!input) {
resultsDiv.innerHTML = "Please enter a location.
";
return;
}
const results = hospitals.filter(hospital =>
hospital.location.toLowerCase().includes(input)
);
if (results.length === 0) {
resultsDiv.innerHTML = "No hospitals found in that location.
";
return;
}
resultsDiv.innerHTML = results.map(h =>
`${h.name}
${h.address}
${h.location}
`
).join('');
}
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok