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

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

WBOY
Release: 2016-05-16 19:55:38
Original
1253 people have browsed it

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 code The code is as follows:







When the a.php page receives the form data, you can use $books = $_REQUEST['books']; to get an array of all book titles.
The method of obtaining 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 gets 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);
}
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template