select下拉框多选的实现

不言
Release: 2018-05-24 14:27:18
Original
12434 people have browsed it

<html>
<head>
<title>select下拉框多选的实现</title>
</head>
<body>
  <select name="category[]" multiple>
    <option value=&#39;php&#39;>php 教程</option>
    <option value=&#39;java&#39; selected>java 教程</option>
    <option value=&#39;mysl&#39;>mysql 教程</option>
    <option value=&#39;js&#39;>js 教程</option>
    <option value=&#39;html&#39;>html 教程</option>
  </select>
</body>
</html>
Copy after login

在线运行

只需要设置select选项框的属性multiple即可实现多选功能。然后在选择的是时候按住ctrl来进行多选。

注意:当select选择框使用了多选的时候,select的name要这样命名category[],需要加上[],否则服务器无法获取到表单post过来的select值。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template