// JavaScript Document
function searchData() {
    var selectedDistrict = document.getElementById("district").value;
    var selectedTehsil = document.getElementById("tehsil").value;
    var selectedConstituency = document.getElementById("constituency").value;
    var selectedUnion_Concils = document.getElementById("union_concils").value;
    var selectedSchool_Level = document.getElementById("school_level").value;
    var selectedSchool_Cate = document.getElementById("school_cate").value;

    // Construct the URL using URLSearchParams
    const url = 'http://localhost/Wajid/server_script.php';

    // Construct the request body
    const body = new URLSearchParams();
    body.append('district', selectedDistrict);
    body.append('tehsil', selectedTehsil);
    body.append('constituency', selectedConstituency);
    body.append('union_concils', selectedUnion_Concils);
    body.append('school_level', selectedSchool_Level);
    body.append('school_cate', selectedSchool_Cate);

    // Make an AJAX request, sending all selected values to the server
    fetch(url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        body: body.toString(),
    })
    .then(response => response.json())
    .then(data => {
        console.log('Data:', data);
        // Process the data and update the UI
        displayResults(data);
    })
    .catch(error => {
        console.error('Error:', error);
        // Handle errors or provide feedback to the user
    });
}