我有一个处于编辑形式的“隐藏输入标签”,其值是从数据库动态加载的。我的问题是,当我编辑表单中的某些内容并按预期方式提交该隐藏的输入标签的值时,但是如果我打开该表单而不触摸表单上的任何内容并单击提交按钮,则存储在该隐藏标签中的值就会更改
按钮-
<button type="submit" class="btn btn-primary pull-right">Save Proforma Invoice</button>
隐藏的输入标签-
<input type="hidden" name="EditBlocksList" id="EditBlocksList" value="<?php echo $PI["blocks"]; ?>">
这是数据库值的var_dump-
string(98) "[{"id":"8","blockNo":"PGPL/001","netCUM":"12.92","adCUM":"17.928","rate":"30000","cost":"387600"}]"
这是print_r($ _ POST)的值;我正在提交-
Array ( [EditCode] => 001 [EditDate] => 16/03/2019 [EditUser] => Jogesh Ravani [EdittMode] => By Road [EditBuyer] => PARADIGAM GRANITE PRIVATE LIMITED [EditsAdd] => SY NO.293/2/3&295/2A/2B/2D/2E/2F, NALLAGANAKOTHAPALLI, HOSUR TALUK, NEAR SHOOLAGIRI, KRISHNAGIRI DIST- 635117 [Editstate] => TAMILNADU [Editgstin] => 33AAFCP5668M1ZW [EditsName] => a [EditsAdd1] => a [EditsState] => a [EditsVillage] => a [EditsPin] => 1 [EditProduct1] => COLOUR GRANITE [EditProduct] => COLOUR GRANITE [Editdescription] => DIMENTIONAL GRANITE ROUGH BLOCK(S) [Edithsn] => 2516 1100 [addBlockNo] => PGPL/001 [newNetCUM] => 12.92 [newadCUM] => 17.928 [newRate] => 30000 [newCost] => 387600
[EditBlocksList] => [{
[EdittotalGrossValue] => 387600 [EdittotaladCUM] => 17.928 [EditrRate] => 3000 [EditrAmt] => 53784 [EditTCUM] => 12.920 [EditTABT] => 441384 [EdittaxType] => INTER-STATE [EdittType] => INTER-STATE [EditpercentIGST] => 12 [EditvalueIGST] => 52966 [EditpercentCGST] => 0 [EditvalueCGST] => 0 [EditpercentSGST] => 0 [EditvalueSGST] => 0 [EditTAAT] => 494350 )
谢谢。
答案 0 :(得分:0)
在尝试查找可能是什么问题之后,我放弃了,并使用以下js函数作为替代。
$(".epiForm").on("click", "button.editPI", function(e) {
e.preventDefault();
editPI();
});
function editPI(){
var Blocklist1 = $("#EditBlocksList1").val();
var Blocklist = $("#EditBlocksList").val();
var code = $("#EditCode").val();
var data = new FormData();
data.append("code", code);
$.ajax({
url:"ajax/pi.ajax.php",
method: "POST",
data: data,
cache: false,
contentType: false,
processData: false,
dataType:"json",
success:function(answer){
var tempBlocklist = answer["blocks"];
if (Blocklist == "") {
$("#EditBlocksList").val(tempBlocklist);
$('.epiForm').submit();
}else{
$('.epiForm').submit();
}
}
})
}
这对我来说很好。