need to catch posted value back in dropdown

<select name="ui3" oninput="load_ui('#ui3')" id="ui3" class="form-control" value="<?php echo isset($_POST["ui3"]) ? $_POST["ui3"] : ''; ?>">
    <option value="IEC 60137: 2017">IEC 60137: 2017</option>
    <option value="ANSI / IEEE C57.19.00/01">ANSI / IEEE C57.19.00/01</option>
    <option value="other">Others</option>
</select>

1 answer

  • answered 2022-05-04 10:07 Haseeb Hassy

    You need to check if post value is equal to dropdown options, like this:

    <select name="ui3" oninput="load_ui('#ui3')" id="ui3" class="form-control">
        <option value="IEC 60137: 2017" <?= isset($_POST["ui3"]) && $_POST["ui3"] == 'IEC 60137: 2017' ? 'selected' : ''; ?>>IEC 60137: 2017</option>
        <option value="ANSI / IEEE C57.19.00/01" <?= isset($_POST["ui3"]) && $_POST["ui3"] == 'ANSI / IEEE C57.19.00/01' ? 'selected' : ''; ?>>ANSI / IEEE C57.19.00/01</option>
        <option value="other" <?= isset($_POST["ui3"]) && $_POST["ui3"] == 'other' ? 'selected' : ''; ?>>Others</option>
    </select>
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum