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