PHP checkbox checkbox value acquisition and checkbox default value output method_PHP tutorial
WBOY
Release: 2016-07-21 15:38:31
Original
957 people have browsed it
How to get checkbox value in php
Copy code The code is as follows:
How to get the checkbox value in php
if( $_POST ) { $value = $_POST['checkbox']; echo 'You selected:'.implode(',',$value); //Due to the checkbox attribute, we must set the name of the checkbox to a if checkbox[] so that php can read it Take it in data form, otherwise the value of the checkbox cannot be read correctly. // Script House jb51.net Organize } ?>
checkbox must use array form when reading the value in php, we read it These values are obtained in the form of an array using php post,
Copy code The code is as follows:
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
php gets the checkbox value of the multi-select box
$ area_arr = array(); if($_GET['action']=="submit"){ $area_arr = $_POST['area']; } echo "You select The specified area is: "; foreach ($area_arr as $k=>$v){ echo $v." "; } ?>
php checkbox default selection problem (all exploited This principle)
Copy code The code is as follows:
>
http://www.bkjia.com/PHPjc/321742.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321742.htmlTechArticlephp method to get the checkbox value. Copy the code as follows: html xmlns="http://www. jb51.net/1999/xhtml" head meta http-equiv="Content-Type" content="text/html; charset=gb231...
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