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 );}