http://docs.jquery.com/Ajax/serialize
On Oct 22, 4:42 pm, Cut <[EMAIL PROTECTED]> wrote: > jQuery List, > > I have 2 form element arrays: > > <input type="hidden" name="rockno[]" value="/* Changes based on rock > id */"> > -and- > <input type="text" name="units[]" value="/* Changes based on selected > rock */"> > > The form's size changes at runtime, so the user can enter as many > rocks as needed. Therefore, the size of the rockno array and units > array are unknown. On the server side, php picks it up: > > $rockno = $_POST['rockno']; > $units = $_POST['units']; > > I don't know how to send this array using javascript or jquery. I've > tried a couple of things, which haven't worked. > > ----------------start code---------------------------- > //doesn't work > var rocksBeforeJoin= $("[EMAIL PROTECTED]'rockno[]']"); > var rocknos = Array.prototype.join.call(rocksBeforeJoin, "~"); > rockno=encodeURIComponent(rockno); > > var unitsBeforeJoin = $("[EMAIL PROTECTED]'units[]']").val(); > var units = Array.prototype.join.call(unitsBeforeJoin, "~"); > units=encodeURIComponent(units); > > //and then,b/c I'm sending 2 variables, I just use standard ajax > > var url="getMinerals.php"; > > request.open("POST", url, true); > request.onreadystatechange = function() {populateMinerals();}; > request.setRequestHeader("Content-Type","application/x-www-form- > urlencoded"); > request.send("rockno=" + rockno + "&units=" + units); > > --------end code--------------- > > In Firebug, after entering 5 rocks into the dynamic form, and hitting > the button which calls the above method, > all I see in the POST is: > > units 2 // <------- This is only one entry, > for the first rock. Where are the other 4? > rockno 2~3~0~4 // <-------- This is only one rockid. Where > are the other 4? > > Thanks for your help, everyone