php如何获取select下拉列表的值

PHPz
Release: 2020-09-05 14:00:38
Original
5263 people have browsed it

php获取select下拉列表的值的方法:首先给select标签添加name属性;然后在表单提交后使用$_POST['name属性值']或$_GET['name属性值']获取select下拉列表的值即可。

php如何获取select下拉列表的值

php获取select下拉列表的值

首先需要给select标签设置name属性,然后表单提交后,用 $_POST 或 $_GET 方式获取提交的值。

_POST['sel']或者$_GET['sel']获得选中的select的value值

<?php
if($_POST)
{
echo $_POST[&#39;select&#39;];
}
?>
<form name="form1" enctype="multipart/form-data" method="post" action="">
<label>
<select name="select">
<option value="1">select下拉列表框的值</option>
<option value="www.php.cn">PHP中文网</option>
<option value="1">值一</option>
<option value="www.php.cn">PHP中文网</option>
<option value="1">select下拉列表框的值</option>
<option value="www.php.cn">PHP中文网</option>
<option value="1">值一</option>
<option value="www.php.cn">PHP中文网</option>
<option value="1">值一</option>
<option value="www.php.cn">select下拉列表框的值WEB第一站</option>
<option value="1">值一</option>
<option value="www.php.cn">PHP中文网</option>
<option value="1">值一</option>
<option value="www.php.cn">中国select下拉列表框的值</option>
<option value="1">值一</option>
<option value="www.php.cn">PHP中文网</option>
<option value="1">select下拉列表框的值</option>
<option value="www.php.cn">PHP中文网</option>
</select>
</label>
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
Copy after login

需要设置name的值。否则无法传递。

更多相关知识,请访问 PHP中文网!!

Related labels:
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