JSFiddle - React, Tailwind, and code Playground
HTML
<form id="frmWithTables">
<table>
<tr><td class="data"><input type="hidden" name="value[]" value="A1.4" /></td></tr>
<tr><td class="data"><input type="hidden" name="value[]" value="A1.5" /></td></tr>
</table>
<table>
<tr><td class="data"><input type="hidden" name="value[]" value="A2.4" /></td></tr>
<tr><td class="data"><input type="hidden" name="value[]" value="A2.5" /></td></tr>
</table>
</form>
JavaScript
// Notice the '[]' behind the name of each input field.
// This will make the script to put all values in an array
/*
You should use it in the ajax like this:
$.ajax({
url: "cek.php",
type:'POST'
data: $('#frmWithTables').serialize(),
cache: false,
success:
function (data) {
$("#cek").val(data);
}
});
Now in cek.php you can acces the values as:
$_POST['value'][0]; // A1.4
$_POST['value'][1]; // A1.5
....
*/
var data = $('#frmWithTables').serialize();
alert('this is what the function produced: '+data);
// There is another function: serializeArray()
jQuery.each($('#frmWithTables').serializeArray(), function(key, val) {
alert(key+' = '+val.value); // Notice val.value! val.name would give you the name of the input
});
// Documentation:
// http://api.jquery.com/serializeArray/
// http://api.jquery.com/serialize/