Home  >  Article  >  Web Front-end  >  select下拉框多选的实现

select下拉框多选的实现

不言
不言Original
2018-05-24 14:27:1812419browse

<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>

在线运行

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

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

Statement:
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