i want to append the value for docid to the html form so that i can send it to the database table,
html code
<form id="upoadfile" class="form-horizontal">
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label"></label>
<div id="carnamediv"></div>
<div class="col-sm-10">
<input type="date" class="form-control" id="uploadate" name="uploadate">
</div>
</div>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label"></label>
<div id="carnamediv"></div>
<div class="col-sm-10">
<input type="file" class="form-control" id="docc" name="docc[]" multiple>
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" style="width:100%" id="docbtn" class="btn btn-primary">Post</button>
<p style="color:blue;" id="posted"></p>
</div>
</form>
function getCurrentApplicationDocuments (searchproductid=''){
var loantable = $('#loandocstable').dataTable({
"processing": true,
"responsive": true,
"serverSide":true,
"destory":true,
"paging":false,
"info":false,
"searching":false,
"ajax": {
url:"serverside/getapplicationsdocs.php",
"data": {
"loanid":searchproductid
},
type: 'post',
},
"columns": [
{data:null,
render: function ( data, type, row ) {
return '<input type="checkbox" >';
}
},
{data: 'id',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'docid');
}
},
{data: 'documentpath'
,
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'documentpath');
}
}
]
});
}
json code,i want when i click editdocbtn,the value for docid to be append to the form
$(document).on("click","#editdocbtn",function (event) {
event.preventDefault();
event.stopPropagation();
var doc = $(this).closest("tr").find("#docid").text();
var myform = document.getElementById('upoadfile');
var data = new FormData(myform);
data.append("id",doc);
});
What I have tried:
have tried the code above but its not working