Phpcheckbox check box value acquisition and checkbox default value output method

Source: Internet
Author: User
Php obtains the checkbox check box value. when using php to read the value, checkbox should be in the form of an array. we can read these values in the form of an array. Php method for obtaining the checkbox check box value

The code is as follows:





Php method for obtaining the checkbox check box value





If ($ _ POST)
{
$ Value = $ _ POST ['checkbox'];
Echo 'you selected:'. implode (',', $ value );
// Because of the checkbox attribute, we must set the name of the checkbox re-selection box to one if checkbox [], so that php can read data in the form of data, otherwise, the value of the checkbox check box cannot be correctly read. // Tidy up jb51.net
}
?>



Checkbox should be in the array format when reading values in php. we can read these values using php post to get them as an array,

The code is as follows:






Php to get the checkbox value of multiple selection boxes


$ Area_arr = array ();
If ($ _ GET ['action'] = "submit "){
$ Area_arr =$ _ POST ['are'];
}
Echo "the region you selected is :";
Foreach ($ area_arr as $ k => $ v ){
Echo $ v ."";
}
?>




Php checkbox default selection problem (this principle is used)

The code is as follows:


>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.