Home >Backend Development >PHP Tutorial >Simple example of php checkbox and select multiple selection values

Simple example of php checkbox and select multiple selection values

WBOY
WBOYOriginal
2016-07-25 09:00:28854browse
Get the value of checkbox or select multi-select column in PHP code, a simple example for beginners’ reference.

The complete code is as follows:

<html>
<head><title>checkbox select取值_bbs.it-home.org</title>
</head>
<body >
<?php $e_ary=array('PHP','C++') ?>
<form name="form1" action="testsubmit.php" method="post">
<input name="choose[]" type="checkbox" value="PHP" <?php if(is_array($e_ary)){ echo in_array('PHP',$e_ary)?'checked':'';} ?>>PHP
<input name="choose[]" type="checkbox" value="VB" <?php if(is_array($e_ary)){ echo in_array('VB',$e_ary)?'checked':'';} ?>>VB
<input name="choose[]" type="checkbox" value="C++" <?php if(is_array($e_ary)){ echo in_array('C++',$e_ary)?'checked':'';} ?>>C++
<select name=select[] multiple>
<option  value="PHP"<?php if(is_array($e_ary)){ echo in_array('PHP',$e_ary)?'selected':'';} ?>>PHP</option>
<option  value="VB" <?php if(is_array($e_ary)){ echo in_array('VB',$e_ary)?'selected':'';} ?>>VB</option>
<option  value="C++" <?php if(is_array($e_ary)){ echo in_array('C++',$e_ary)?'selected':'';} ?>>C++</option>
</select>
<input name="submit" type="submit" value="submit">
</form>
</body>
</html>


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