Page Reload on Radio Button Selection

Select a status. The page reloads with the selected value in the query string and PHP keeps the matching radio button selected.

Selected value: All

Validate the Query String in PHP Top ↑

$allowedStatus = [
    'All',
    'Live',
    'Failed',
    'Matured'
];

$enqStatus =
    $_GET['enq_status'] ?? 'All';

if (
    !in_array(
        $enqStatus,
        $allowedStatus,
        true
    )
) {
    $enqStatus = 'All';
}

See PHP switch if your application maps each allowed value to different behavior.

Reload the Page after Radio Selection Top ↑

$( 'input[name="enq_status"]' )
    .on( "change", function () {
        const params = new URLSearchParams({
            enq_status: $( this ).val()
        });

        window.location.assign(
            "radio-button-submit.php?" +
            params.toString()
        );
    });
If the selected value is used in SQL, map the validated status to prepared-query parameters rather than concatenating the query string directly into SQL.

Additional Original Learning Routes Top ↑

These original tutorial/demo routes are retained so no useful learner path is lost:






plus2net.com






We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer