The HTML drop-down menu keeps the selected value after submission without returning to the default value


Copy code

The code is as follows:

//Get select value
$select_value = isset($_GET[‘select’]) ? $_GET[‘select’] : ”;
<form action=”?”>
<select name=”select”>
<option value=””>default</option>
<option value=”option1″ <?php
//If the value obtained above is the same as the value in this option,
//Print selected, so that the option is selected by default
echo $select_value == ‘option1’ ? ‘selected’ : ”
<input type=”submit” value=”submit” />

This script should be added to each option. If there are more than one option, you can print in cycles.

Recommended Today

The use of progressbarcontrol, a progress bar control of devexpress – Taking ZedGraph as an example to add curve progress

scene WinForm control – devexpress18 download installation registration and use in vs: When using ZedGraph to add curves, the number of curves is slower if there are many cases. So in the process of adding curve, the progress needs to be displayed, and the effect is as follows     Note: Blog home page: […]