我想显示以前填写的一些数据中的数据。但是我遇到问题,执行查询时无法获取所需的数据 在这种情况下,我必须寻呼。一种javascript和一种html。这是我的代码:
** javascript **
function addTableRowHasilProduksi() {
row = parseInt($('#tableRowHasilProduksi').val()) + 1;
$('#plusButtonHasilProduksi').remove();
//var tableRow = document.getElementById("rowTableHasilProduksi_"+row);
//var tableRowClone = tableRow.cloneNode(true);
//tableRow.parentNode.insertBefore(tableRowClone, tableRow.nextSibling)
var html = ' \
<tr id="rowTableHasilProduksi_' + row + '"> \
<td><button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal" onclick="row='+row+'"><b>Cari</b> <span class="glyphicon glyphicon-search"></span></button></td> \
<td> \
<input type="text" class="form-control" name="typepartid_' + row + '" id="typepartid_' + row + '" placeholder="Masukkan Part" readonly="" />\
</td> \
<td> \
<input type="text" class="form-control" name="typepartname_' + row + '" id="typepartname_' + row + '" placeholder="Masukkan Part" readonly="" />\
</td> \
<td> \
<input type="text" class="form-control" name="unitid_' + row + '" id="unitid_' + row + '" readonly="" />\
</td> \
<td id="tdTypeReject_' + row + '"> \
<select id="locationid_' + row + '" class="form-control" name="locationid_' + row + '"> \
' + htmlTypeReject + ' \
</select> \
</td> \
<td><input id="qtystock_' + row + '" type="number" class="form-control" name="qtystock_' + row + '" /> \
</td> \
<td><input id="qty_' + row + '" type="number" class="form-control" name="qty_' + row + '" /> \
</td> \
<td><div class="input-group"><input id="mprosector_' + row + '" class="form-control" type="text" name="mprosector_' + row + '" readonly="readonly"><span class="input-group-btn"><button type="button" class="btn btn-default glyphicon glyphicon-folder-open" data-toggle="modal" data-target="#mprosectorModal" onclick="row='+row+'"></button></span></div>\
</td> \
<td><input id="keteranganreject_' + row + '" type="text" class="form-control" name="keteranganreject_' + row + '"/></td> \
<td><button type="button" class="btn btn-sm btn-default" onclick="deleteRowHasilProduksi(' + row + ')">x</button></td> \
</tr> \
<tr id="plusButtonHasilProduksi"> \
<td colspan="9"><button type="button" class="btn btn-sm btn-success" style="width:100%" onclick="addTableRowHasilProduksi();">TAMBAH</button></td> \
</tr>';
$('#tableHasilProduksi > tbody').append(html);
$('#tableRowHasilProduksi').val(row);
$("#locationid_"+row).change(function() {
var partid = $("#typepartid_"+row).val();
var location = $("#locationid_"+row).val();
$.ajax({
url : "api/hitungstock.php",
data : "partid="+partid+
"&location="+location,
success : function(data) {
$('#qtystock_' + row).val(data);
}
});
});
}
html
<div class="modal fade" id="mprosectorModal" tabindex="-1" role="dialog" aria-labelledby="mprosectorModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width:70%">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="mprosectorModalLabel">Cari MPRO Sector</h4>
</div>
<div class="modal-body">
<table id="mprosector" class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>LocationID</th>
<th>Keterangan</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<?php
//Data mentah yang ditampilkan ke tabel
include 'config/db.php';
$partid = $_GET['partid'];
$sql = "SELECT
a.LocationID,
a.Keterangan,
ISNULL((
SELECT
SUM (Qty)
FROM
Buku_Stock201905
WHERE
PartID = '$partid'
AND LocationID = a.LocationID
),0) AS qty
FROM
Ms_WarehouseStock a
WHERE
a.Aktif = 1
ORDER BY
a.LocationID";
$s = sqlsrv_query($conn, $sql);
while ($data = sqlsrv_fetch_array($s, SQLSRV_FETCH_ASSOC)) {
?>
<tr class="pilihmprosector" data-kodesector="<?php echo $data['LocationID']; ?>">
<td><?php echo $data['LocationID']; ?></td>
<td><?php echo $data['Keterangan']; ?></td>
<td><?php echo $data['qty']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
这是我程序的一些屏幕截图
我要在typepertid_ +行中输入数据。然后可以在我的mpro扇区中解析该值,以便我可以使用typepertid_ + row
中的值进行查询