简体   繁体   中英

How to retrieve the selected value from dropdown and display it in the same dropdown box

I have three dropdown boxes . Namely DS , QA , Mod . First step is DS will select a value (YES/NO) & upon submitting, QA will be reviewing the input of DS. I have to get the values of DS Dropdown and display it in the same dropdown box of DS(disabled) when QA is about to check the input.Same goes with Mod.Take note that these dropdown boxes exists in checklist.php file.

 <table width="100%" border="1"> <tbody> <tr> <td align="left" rowspan="2"><b>Check Items</b></th> <td><b>DS</b></td> <td><b>QA</b></td> <td><b>Mod?</b></td> </tr> <tr> <td align="center" rowspan="2"><select id="valueDS1"> <option value="YD1">YES</option> <option value ="NAD1">N/A</option> </select> </td> <td align="center" rowspan="2"><select id="valueQA1"> <option value="YQ2">YES</option> <option value ="NAQ2">N/A</option> </select> </td> <td align="center" rowspan="2"><select id="valueMod1"> <option value="YM1">YES</option> <option value ="NM1">NO</option> </select> </td> </tr> <tr> <td>&nbsp;All extra instructions and corrections applied.</td> <tr> <td> <p>&nbsp;If comments exist, ask DE if they need to be deleted or retained (but hidden)</p> </td> <td align="center"><select id="valueDS2"> <option value="Y">YES</option> <option value ="NA">N/A</option> </select> </td> <td align="center"><select id="valueQA2"> <option value="Y">YES</option> <option value ="NA">N/A</option> </select> </td> <td align="center"><select id="valueMod2"> <option value="Y">YES</option> <option value ="NA">NO</option> </select> </td> </tr> </table>

Inside the PHP code, assign a variable to the dropdown. $DS= $_POST['DS']

Now, in the HTML of the dropdown do something like following

<select>
    <option <?php if(isset($DS) && $DS=="yes" ){ echo "selected"; } ?> value="yes" disabled>Yes</option>
</select>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM