简体   繁体   中英

Edit form and get all values (like array) from javascript to php

I need to edit books values (quantity) on a form, and finally use Ajax to load it into db. But I don't know how to use an associative array to pass url from ajax, like this:

xmlhttp.open("GET", "send.php?q=" + arrayassosiative, true);    

Form (after php load):

<input type="text" class="bookclass" name="bookid[1]" />
<input type="text" class="bookclass" name="bookid[2]" />
<input type="text" class="bookclass" name="bookid[3]" />    

JavaScript:

var arr = new Array();
var elems = document.querySelectorAll('.bookclass'); // class

for ( var i=0; i<elems.length; i++ ) {
    arr.push(elems[i].value)
}    

But isn't associative array, so what can I do?

在文件周围创建一个表单,并使用form_selector.serialize()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM