After submitting the html drop-down menu, the selected value is retained instead of returning to the default value

After submitting the html drop-down menu, the selected value is retained instead of returning to the default value

Copy code
The code is as follows:

<html>
<body>
<?php
// Get the 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, making this option selected by default
echo $select_value == 'option1' ? 'selected' : ''
?>>option1</option>
</select>
<input type="submit" value="submit" />
</form>
</body>
</html>

This script should be added to each option, and if there are multiple options, they can be printed in a loop.

<<:  Solution to css3 transform transition jitter problem

>>:  Implementing a simple age calculator based on HTML+JS

Recommend

Webpack builds scaffolding to package TypeScript code

Create a folder Directory structure: dabaots Init...

CSS3 realizes the mask barrage function

Recently I saw a barrage effect on B station call...

Full analysis of MySQL INT type

Preface: Integer is one of the most commonly used...

Detailed explanation of anonymous slots and named slots in Vue

Table of contents 1. Anonymous slots 2. Named slo...

Vue implements book management case

This article example shares the specific code of ...

How to start and stop SpringBoot jar program deployment shell script in Linux

Without further ado, let me give you the code. Th...

js implements axios limit request queue

Table of contents The background is: What will ha...

A simple LED digital clock implementation method in CSS3

This should be something that many people have do...

MySQL Best Practices: Basic Types of Partition Tables

Overview of MySQL Partitioned Tables As MySQL bec...

js to implement collision detection

This article example shares the specific code of ...

Several ways to introduce pictures in react projects

The img tag introduces the image Because react ac...

Learn how to write neat and standard HTML tags

Good HTML code is the foundation of a beautiful w...

Use of Docker UI, a Docker visualization management tool

1. Introduction to DockerUI DockerUI is based on ...

Using Docker+jenkins+python3 environment to build a super detailed tutorial

Preface: After the automation is written, it need...