表行本身将在运行时由javascript创建
function addRow_tugas_rkb(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length - 2;
var row = table.insertRow(rowCount);
var cell6 = row.insertCell(0);
var cell5 = row.insertCell(0);
var cell4 = row.insertCell(0);
var cell3 = row.insertCell(0);
var cell2 = row.insertCell(0);
var cell1 = row.insertCell(0);
cell1.innerHTML="<button type='button' onclick='delRow_tugas_rkb(this)' style='width:25px;height:25px;font-size:15px;' class='btn btn-floating btn-danger btn-sm'><i class='icon icon fa-minus' aria-hidden='true'></i></button>";
var element2 = document.createElement("textarea");
element2.className="form-control ket_rkb";
element2.name = "ket_rkb[]";
element2.rows = "2";
element2.cols = "70";
cell2.appendChild(element2);
var element3 = document.createElement("input");
element3.className="form-control bobot_rkb";
element3.type = "text";
element3.style.width = "45px";
element3.name = "bobot_rkb[]";
element3.onchange=hitung_bobot;
cell3.appendChild(element3);
var element4 = document.createElement("input");
element4.className="form-control target_rkb";
element4.type = "text";
element4.style.width = "45px";
element4.name = "target_rkb[]";
cell4.appendChild(element4);
我认为select2倍数不能与像这样的数组一起使用[]
cell5.innerHTML="<select name='nrk_turunan[]' class='nrk_turunan' multiple='multiple' onchange=''>"+
"<?php
$query = "SELECT NRK,NAMA FROM persoeis@SIMPERS WHERE KD_PEL||KD_DIT||KD_SUB IN (select KD_PEL||KD_DIT||KD_SUB
from persoeis@SIMPERS where nrk = $dapatNRK ) AND jenpeg not in ('4','7','9','c','d','r') AND KD_JNS_JABATAN='1'
UNION
SELECT NRK_PEG NRK,NAMA_PEG NAMA FROM TBL_ATASAN_STRUKTURAL_KOSONG WHERE NRK_ATASAN=$dapatNRK AND KD_PEL_ATASAN||KD_DIT_ATASAN||KD_SUB_ATASAN||KD_SEK_ATASAN=$vargabungkode";
<code>
$sqlquery = oci_parse($conn, $query);
oci_execute($sqlquery);
while($row=oci_fetch_array($sqlquery)){
if ($dapatNRK == $row['NRK']) continue;
echo "<option value='".$row['NRK']."|".$row['NAMA']."'>".$row['NAMA']."</option>";
}
?> </select>";
$(".nrk_turunan").select2({
placeholder: "PILIH"
});
。
cell6.innerHTML="<input type='checkbox' name='chkbox_ulangi_rkb[]' id='chkbox_ulangi_rkb[]' onchange='check_ulang_javas(this)'><input type='hidden' name='check_ulang[]' value='0'>";
}
function delRow_tugas_rkb(row) {
var i=row.parentNode.parentNode.rowIndex;
var k=i;
var bobot = document.getElementsByName("bobot_rkb[]");
var total_bobot = document.getElementById("total_bobot");
var iInt = parseInt(k) - 2;
var intBobot = parseInt(bobot[iInt].value);
total_bobot.value = parseInt(total_bobot.value) - intBobot;
document.getElementById('input_rkb').deleteRow(i);
}
插入语句(save.php)
foreach($_POST['ket_rkb'] as $key => $value) {
if ($value) {
$ket_rkb = htmlspecialchars(escapeSQL(trim($_POST['ket_rkb'][$key])));
$bobot_rkb = trim($_POST['bobot_rkb'][$key]);
$target_rkb = trim($_POST['target_rkb'][$key]);
$check_ulang = $_POST['check_ulang'][$key];
$rkbInsertDet = "INSERT INTO RKB_PEGAWAI_DETAIL
(ID_RKB, RKB, BOBOT,TARGET,FLAG_ULANGI) VALUES ('$get_id_rkb','$ket_rkb','$bobot_rkb','$target_rkb','$check_ulang')
returning ID into :ID_RKB_DETAIL";
$obParse = oci_parse($conn, $rkbInsertDet);
oci_bind_by_name($obParse, ":ID_RKB_DETAIL", $get_id_detail, 32);
$objExecute = oci_execute($obParse, OCI_DEFAULT);
//select2 multiple for lopp. whats wrong with my code ??
foreach ($_POST['nrk_turunan'] as $key => $value2) {
if ($value2){
$KD_NM_NRK = explode("|",$value2);
$rkbInsertTurunan = "INSERT INTO RKB_TURUNAN_PEG (ID_RKB_DETAIL, NRK, NAMA_PEG) VALUES ('$get_id_detail','$KD_NM_NRK[0]','$KD_NM_NRK[1]')";
$obParse = oci_parse($conn, $rkbInsertTurunan);
$objExecute = oci_execute($obParse, OCI_DEFAULT);
}
}
}
}
if ($objExecute)
{
oci_commit($conn);
}else{
oci_rollback($conn);
}
我的问题是:
select2 multiple不起作用,如何对具有多个数据的select2进行循环
我想要这样的结果 enter image description here
我的代码有什么问题..
有人/任何人都可以帮助我吗?
对不起我的英语不好