Home  >  Article  >  Backend Development  >  PHP ci code to obtain the values ​​of multiple input elements with the same name in the form

PHP ci code to obtain the values ​​of multiple input elements with the same name in the form

WBOY
WBOYOriginal
2016-07-29 08:56:02965browse

Sometimes the front page needs to allow the dynamic addition/deletion of multiple values ​​​​of a certain attribute, such as adding books to the bookshelf, and the ability to dynamically add or delete books. There will be multiple input elements in the form on the front page, as follows:

Copy the code The code is as follows:






< input type="submit" name="submit" />

When the a.php page receives the form data, you can use $books = $_REQUEST['books']; to get all Array of book titles.
How to obtain data through post in PHP CI: $books = $this->input->post('books');//Note that this is books, and the form name is books[] in the form of an array

js to get the values ​​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);
}

The above introduces the code for php ci to obtain the values ​​of multiple input elements with the same name in the form, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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
Previous article:Small case: micro blogNext article:Small case: micro blog