我使用AppendGrid作为包含标题和详细信息的表插入表单的插件。
这是我的代码:
$('#tblAppendGrid').appendGrid({
initRows: 1,
columns: [
{ name: 'CodeNo', display: 'Code No', type: 'text', ctrlCss: { 'text-align': 'center' },ctrlAttr: { maxlength: '10' }},
{ name: 'CartonNo', display: 'Carton No', type: 'text', ctrlCss: {'text-align': 'center'},ctrlAttr: { maxlength: '10' }},
{ name: 'JawNo', display: 'Jaw No', type: 'text',ctrlCss: { 'text-align': 'center' },ctrlAttr: { maxlength: '10' }},
{ name: 'Time', display: 'Time', type: 'text', ctrlAttr: { maxlength: '10' },
ctrlCss: {'text-align': 'center' }, value: '<?php echo"$jam_ini";?>'},
{ name: 'wos', display: 'Weight Of Sample(67-72 g)',
type: 'text', ctrlAttr: { maxlength: 10 }, ctrlCss: { 'text-align': 'center' }},
{ name: 'odour', display: 'Odour/flavour&Taste (Normal)*',
type: 'select', ctrlOptions: {V: 'V',X: 'X'},ctrlCss: {'align': 'center' }},
{ name: 'ph', display: 'pH(6,0-6,4)', type: 'text', ctrlAttr: { maxlength: '10' }, ctrlCss: {'text-align': 'center' }},
{ name: 'et', display: 'Electrolit Test (Negative)', type: 'select', ctrlOptions: {N: 'N',P: 'P'}
,ctrlCss: {'align': 'center' }},
{ name: 'it', display: 'Ink. Test(Negative)**', type: 'select', ctrlOptions: {N: 'N',P: 'P','':''},
ctrlCss: {'align': 'center' }},
{ name: 'remark', display: 'Remark', type: 'text', ctrlAttr: { maxlength: '10' }, ctrlCss: {'text-align': 'center' }}
]
});
// Dummy: Handle save button clicked
$('#tombolsave').button().click(function () {
$("#status").html("Saving...");
$("#loading").show();
var HeaderID = $("#HeaderID").val();
var UserName = $("#UserName").val();
var date = $("#date").val();
var bop = $("#bop").val();
var pdate = $("#pdate").val();
var exdate = $("#exdate").val();
var line = $("#line").val();
var toi = $("#toi").val();
var data = $('#tblAppendGrid').appendGrid('getAllValue');
var count = $('#tblAppendGrid').appendGrid('getRowCount');
for (var i=0;i<=count;i++){
var CodeNo = data[i].CodeNo;
var CartonNo = data[i].CartonNo;
var JawNo = data[i].JawNo;
var Time = data[i].Time;
var wos = data[i].wos;
var odour = data[i].odour;
var ph = data[i].ph;
var et = data[i].et;
var it = data[i].it;
var remark = data[i].remark;
alert(it);
$.ajax({
type:'POST',
url: "aksi.php",
data: "op=save&HeaderID="+HeaderID+"&UserName="+UserName+"&date="+date+"&bop="+bop+
"&pdate"+pdate+"&exdate="+exdate+
"&line="+line+"&toi"+toi+"&i="+i+
"&CodeNo[]="+CodeNo+"&CartonNo[]"+CartonNo+"&JawNo[]="+JawNo+
"&Time[]="+Time+"&wos[]"+wos+"&odour[]="+odour+"&ph[]="+ph+"&et[]"+et+"&it[]="+it+
"&remark[]="+remark,
cache: false,
success: function(msg){
if(msg=="sukses"){
$("#status").html("Berhasil...");
$("#loading").hide();
document.location.reload();
}else{
$("#status").html("ERROR..");
}
}
});
}
});
});
我在AJAX POST中的问题,如何发布每个细节值以及如何在 aksi.php 中使用它。 希望这有意义。
答案 0 :(得分:0)
没有错,您只是忘记在"&CartonNo[]"+CartonNo
到"&CartonNo[]="+CartonNo
在aksi.php上只需创建一个类似
的数组//script connect to database
for($i = 0; $i< $max; $i++){
//detail
$CartonNo = $_POST[CartonNo][$i];
....
//sql action
}