How to receive check box information in PHP development _php Tutorial

Source: Internet
Author: User
PHP (as the current mainstream development language) to receive more than the same name check box information is not automatically converted into an array like ASP, which brings some inconvenience to use. But there is still a solution, that is, using JavaScript to do preprocessing. More than one check box with the same name exists in JavaScript or as an array, so you can use JavaScript to synthesize a character array from the information group in the check box to the hidden elements in the form before the form is submitted, and then use PHP (as the current mainstream development language) The EXPLODE function resolves this array so that the check box information can be passed. The following examples illustrate.

Suppose you have a form like this:


1

2

3

4

This form has a check box with four names that are item, and when the user clicks the Submit button, the checker function is called, and if Checker returns True, the form is committed, and the return false form is not committed. Here the checker function is the preprocessing function we are going to write. Add the following JavaScript in the header section of the HTML:

This makes it possible to combine the value of all selected checkboxes into an array of strings in myphp (as the current mainstream development language). PHP (as the current mainstream development language) uses such statements:

$items = Explode ("", $HTTP _post_vars["items"]);

You can separate these options into arrays. It is important to note that the value in the option cannot contain a delimiter (this is a space).

http://www.bkjia.com/PHPjc/508677.html www.bkjia.com true http://www.bkjia.com/PHPjc/508677.html techarticle PHP (as the current mainstream development language) to receive more than the same name check box information is not automatically converted into an array like ASP, which brings some inconvenience to use. But there is a solution, ...

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