Php ci gets code for multiple input element values with the same name in the form, ciinput

Source: Internet
Author: User

Php ci gets code for multiple input element values with the same name in the form, ciinput

Sometimes the front-end page allows you to dynamically Add/delete multiple values of a certain attribute. For example, you can add or delete a book to the bookshelf dynamically. The form on the front-end page contains multiple input elements, as shown below:
Copy codeThe Code is as follows:
<Form action = "a. php">
<Input type = "text" name = "books []"/>
<Input type = "text" name = "books []"/>
<Input type = "text" name = "books []"/>
<Input type = "submit" name = "submit"/>
</Form>

When receiving form data on the. php page, you can use $ books = $ _ REQUEST ['books ']; To obtain an array of all titles.
In php ci, the data obtained through post is: $ books = $ this-> input-> post ('books '); // note that here is books, in the form name, books [] is an array.

Js gets the value of multiple input boxes with the same name

Var els = document. getElementsByName ("books"); for (var I = 0, j = els. length; I <j; I ++) {alert (els [I]. value );}

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.