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