简体   繁体   中英

Maintain dropdown selected value after submisson

I have a form with a dropdown list and I am using select2 plugin for searchable dropdown. If there is an error on form submission the form page redirect with a message and the selected drop down value lose it value and user have to reselect it. How can I maintain the drop down value?

尝试这个

<option <?php if(isset($_POST['name_of_this_dropdown'])){echo 'selected';};?>>some_value_here</option>

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