Home > OS >  need to catch posted value back in dropdown
need to catch posted value back in dropdown

Time:05-04

<select name="ui3" oninput="load_ui('#ui3')" id="ui3"  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>

CodePudding user response:

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

<select name="ui3" oninput="load_ui('#ui3')" id="ui3" >
    <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>
  • Related