How to get data/value from with dynamic rowspan
up vote
0
down vote
favorite
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<?php
$prevMonth = $prevPo = $prevDo = $prevKeyResin = "";
$rowspan=$total_kage=0;
$results = $conn->query("SELECT PCAP.id,MP.part_number,MP.part_name,M.name,MR.resin,PCAP.qty,PC.po_number,MP.cavity,MP.weight_product,MP.weight_runner,PC.month
,CONCAT (MR.resin) AS KeyResin
,CONCAT (DATE_FORMAT(PC.month,'%M %Y')) AS KeyMonth
,CONCAT (PC.po_number) AS KeyPo
,CONCAT (MR.resin) AS KeyName
FROM po_customer_add_product PCAP
LEFT JOIN po_customer PC ON PC.id=PCAP.po_customer_id
LEFT JOIN master_product MP ON MP.id=PCAP.product_id
LEFT JOIN master_resin MR ON MR.id=MP.material_name
LEFT JOIN master M ON M.id=PCAP.customer
Where PCAP.active='1' AND PCAP.open_po_resin='0'
Order BY PC.month ASC,MR.resin ASC ");
// fetch pertama, utk cari jumlah rowspan dan Total(Kg)
$rowspan = $rowname = $rowpo = $rowmon = $total_kage = 0;
$prevName = $prevPO = $prevMonth = $prevKeyResin = "";
$arrTotal = $arrRowSpan = array();
while($row = $results->fetch_array()) {
$pcapid = $row['id'];
$KeyName = $row['KeyName'];
if($KeyName!=$prevName) { $prevName=$KeyName; $rowname=1; } else { $rowname++; }
$arrRowSpan[$KeyName] = $rowname;
$KeyMonth = $row['KeyMonth'];
if($KeyMonth!=$prevMonth) { $prevMonth=$KeyMonth; $rowmon=1; } else { $rowmon++; }
$arrRowSpan[$KeyMonth] = $rowmon;
$KeyPo = $row['KeyPo'];
if($KeyPo!=$prevPo) { $prevPo=$KeyPo; $rowpo=1; } else { $rowpo++; }
$arrRowSpan[$KeyPo] = $rowpo;
$KeyResin = $row['KeyResin'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
if($KeyResin != $prevKeyResin) {
$prevKeyResin = $KeyResin;
$total_kage = $weighttotal;
$rowspan = 1;
} else {
$total_kage += $weighttotal;
$rowspan++;
}
$arrTotal[$KeyResin] = array( 'rowspan' => $rowspan, 'total_kage' => $total_kage );
}
$prevName = $prevPo = $prevMonth = $prevKeyResin = "";
$results->data_seek(0); // balikin lagi ke row[0]
while($row = $results->fetch_array()) {
$Name = $row['resin'];
$PO = $row['po_number'];
$Month = date('F Y',strtotime($row['month']));
$KeyName = $row['KeyName'];
$KeyMonth = $row['KeyMonth'];
$KeyResin = $row['KeyResin'];
$KeyPo = $row['KeyPo'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
$td_name = $td_month = $td_po = $ttl_kg = $ttl_kg1 = $ttl_kg2 = $ttl_kg3 = "";
if($KeyName!=$prevName) {
$prevName = $KeyName; $rowspan = $arrRowSpan[$KeyName];
$td_name = "<td rowspan='$rowspan' class='td-name'>$Name</td>";
}
if($KeyMonth!=$prevMonth) {
$prevMonth = $KeyMonth; $rowspan = $arrRowSpan[$KeyMonth];
$td_month = "<td rowspan='$rowspan' class='td-month'>$Month</td>";
}
if($KeyPo!=$prevPo) {
$prevPo = $KeyPo; $rowspan = $arrRowSpan[$KeyPo];
$td_po = "<td rowspan='$rowspan'>$PO</td>";
}
if($KeyResin != $prevKeyResin) {
$mulai = new DateTime($row['month']);
$mulai->add(new DateInterval('P1M'));
$sampe = new DateTime('+7 month');
$interval = new DateInterval('P1M');
$rangetgl = new DatePeriod($mulai, $interval ,$sampe);
$option = "";
foreach($rangetgl as $tgl){
$dateid = $tgl->format("Y-m");
$dateoption = $tgl->format("F Y");
$option .= "<option value='$dateid'>$dateoption</option>";
};
$prevKeyResin = $KeyResin;
$rowspan = $arrTotal[$KeyResin]['rowspan'];
$total_kage = $arrTotal[$KeyResin]['total_kage'];
$ttl_kg = "<td rowspan='$rowspan' class='td-weighttotal'>$total_kage</td>";
$ttl_kg1 = "<td rowspan='$rowspan' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
$option
</select>
</td>
";
$ttl_kg2 = "<td rowspan='$rowspan'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
";
$ttl_kg3 = "<td rowspan='$rowspan'><button class='btnSelect'>Order</button>
";
}
?>
<?php
echo "<tr>
<td class='td-id'>".$row['id']."</td>
<td class='td-customer'>".$row['name']."</td>
$td_month
<td class='td-po'>".$row['po_number']."</td>
<td class='td-partnumber'>".$row['part_number']."</td>
<td class='td-partname'>".$row['part_name']."</td>
<td class='td-qtypcs'>".$row['qty']."</td>
$td_name
$ttl_kg
$ttl_kg1
$ttl_kg2
$ttl_kg3
</tr>";
}
?>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
result browser
only 1 id show and order resin (kg) now show
this code no use connection to db
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
table {width:100%;}
th {background-color: #4CAF50;color: white;}
table, th, td {border: 1px solid black;border-collapse: collapse;}
th, td {padding: 15px;text-align: left;}
table#t01 tr:nth-child(even) {background-color: #eee;}
table#t01 tr:nth-child(odd) {background-color: #fff;}
table#t01 th { background-color: black;color: white;}
.btnSelect {
background-color: #f44336;
border: 2px solid #f44336;
border-radius: 4px;
color: white;
cursor: pointer;
}
.btnSelect:hover{
background-color: #c93326; border: 2px solid #c93326;
}
</style>
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<tr>
<td class='td-id'>99</td>
<td class='td-customer'>ASMO</td>
<td rowspan='7' class='td-month'>December 2018</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-4-4</td>
<td class='td-partname'>ASMO4</td>
<td class='td-qtypcs'>1002</td>
<td rowspan='3' class='td-name'>DELRIN 111 PA (NC)</td>
<td rowspan='3' class='td-weighttotal'>74.511</td>
<td rowspan='3' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='3'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='3'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>101</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y1</td>
<td class='td-partname'>YAMAHA1</td>
<td class='td-qtypcs'>2000</td>
</tr><tr>
<td class='td-id'>103</td>
<td class='td-customer'>DENSO</td>
<td class='td-po'>DENSO1</td>
<td class='td-partnumber'>D1</td>
<td class='td-partname'>D1-11</td>
<td class='td-qtypcs'>3000</td>
</tr><tr>
<td class='td-id'>98</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-3-3</td>
<td class='td-partname'>ASMO3</td>
<td class='td-qtypcs'>1001</td>
<td rowspan='2' class='td-name'>DURACON M90-44 (NC)</td>
<td rowspan='2' class='td-weighttotal'>7.25425</td>
<td rowspan='2' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='2'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='2'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>97</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-2-2</td>
<td class='td-partname'>ASMO2</td>
<td class='td-qtypcs'>1000</td>
</tr><tr>
<td class='td-id'>100</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-5-5</td>
<td class='td-partname'>ASMO5</td>
<td class='td-qtypcs'>1003</td>
<td rowspan='1' class='td-name'>IUPILON S 3000 R (BK)</td>
<td rowspan='1' class='td-weighttotal'>28.209375</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>102</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y2</td>
<td class='td-partname'>YAMAHA2</td>
<td class='td-qtypcs'>2000</td>
<td rowspan='1' class='td-name'>LLDPE F-410 (NC)</td>
<td rowspan='1' class='td-weighttotal'>32.5</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
How to get value from "td" with dynamic rowspan ?
already tried but no lucky.
already read on
Jquery - get value of <td> tag that has rowspan more than one
How to get the table row td's value that has a row span column
, but no same case
help me
javascript php jquery mysql ajax
|
show 6 more comments
up vote
0
down vote
favorite
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<?php
$prevMonth = $prevPo = $prevDo = $prevKeyResin = "";
$rowspan=$total_kage=0;
$results = $conn->query("SELECT PCAP.id,MP.part_number,MP.part_name,M.name,MR.resin,PCAP.qty,PC.po_number,MP.cavity,MP.weight_product,MP.weight_runner,PC.month
,CONCAT (MR.resin) AS KeyResin
,CONCAT (DATE_FORMAT(PC.month,'%M %Y')) AS KeyMonth
,CONCAT (PC.po_number) AS KeyPo
,CONCAT (MR.resin) AS KeyName
FROM po_customer_add_product PCAP
LEFT JOIN po_customer PC ON PC.id=PCAP.po_customer_id
LEFT JOIN master_product MP ON MP.id=PCAP.product_id
LEFT JOIN master_resin MR ON MR.id=MP.material_name
LEFT JOIN master M ON M.id=PCAP.customer
Where PCAP.active='1' AND PCAP.open_po_resin='0'
Order BY PC.month ASC,MR.resin ASC ");
// fetch pertama, utk cari jumlah rowspan dan Total(Kg)
$rowspan = $rowname = $rowpo = $rowmon = $total_kage = 0;
$prevName = $prevPO = $prevMonth = $prevKeyResin = "";
$arrTotal = $arrRowSpan = array();
while($row = $results->fetch_array()) {
$pcapid = $row['id'];
$KeyName = $row['KeyName'];
if($KeyName!=$prevName) { $prevName=$KeyName; $rowname=1; } else { $rowname++; }
$arrRowSpan[$KeyName] = $rowname;
$KeyMonth = $row['KeyMonth'];
if($KeyMonth!=$prevMonth) { $prevMonth=$KeyMonth; $rowmon=1; } else { $rowmon++; }
$arrRowSpan[$KeyMonth] = $rowmon;
$KeyPo = $row['KeyPo'];
if($KeyPo!=$prevPo) { $prevPo=$KeyPo; $rowpo=1; } else { $rowpo++; }
$arrRowSpan[$KeyPo] = $rowpo;
$KeyResin = $row['KeyResin'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
if($KeyResin != $prevKeyResin) {
$prevKeyResin = $KeyResin;
$total_kage = $weighttotal;
$rowspan = 1;
} else {
$total_kage += $weighttotal;
$rowspan++;
}
$arrTotal[$KeyResin] = array( 'rowspan' => $rowspan, 'total_kage' => $total_kage );
}
$prevName = $prevPo = $prevMonth = $prevKeyResin = "";
$results->data_seek(0); // balikin lagi ke row[0]
while($row = $results->fetch_array()) {
$Name = $row['resin'];
$PO = $row['po_number'];
$Month = date('F Y',strtotime($row['month']));
$KeyName = $row['KeyName'];
$KeyMonth = $row['KeyMonth'];
$KeyResin = $row['KeyResin'];
$KeyPo = $row['KeyPo'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
$td_name = $td_month = $td_po = $ttl_kg = $ttl_kg1 = $ttl_kg2 = $ttl_kg3 = "";
if($KeyName!=$prevName) {
$prevName = $KeyName; $rowspan = $arrRowSpan[$KeyName];
$td_name = "<td rowspan='$rowspan' class='td-name'>$Name</td>";
}
if($KeyMonth!=$prevMonth) {
$prevMonth = $KeyMonth; $rowspan = $arrRowSpan[$KeyMonth];
$td_month = "<td rowspan='$rowspan' class='td-month'>$Month</td>";
}
if($KeyPo!=$prevPo) {
$prevPo = $KeyPo; $rowspan = $arrRowSpan[$KeyPo];
$td_po = "<td rowspan='$rowspan'>$PO</td>";
}
if($KeyResin != $prevKeyResin) {
$mulai = new DateTime($row['month']);
$mulai->add(new DateInterval('P1M'));
$sampe = new DateTime('+7 month');
$interval = new DateInterval('P1M');
$rangetgl = new DatePeriod($mulai, $interval ,$sampe);
$option = "";
foreach($rangetgl as $tgl){
$dateid = $tgl->format("Y-m");
$dateoption = $tgl->format("F Y");
$option .= "<option value='$dateid'>$dateoption</option>";
};
$prevKeyResin = $KeyResin;
$rowspan = $arrTotal[$KeyResin]['rowspan'];
$total_kage = $arrTotal[$KeyResin]['total_kage'];
$ttl_kg = "<td rowspan='$rowspan' class='td-weighttotal'>$total_kage</td>";
$ttl_kg1 = "<td rowspan='$rowspan' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
$option
</select>
</td>
";
$ttl_kg2 = "<td rowspan='$rowspan'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
";
$ttl_kg3 = "<td rowspan='$rowspan'><button class='btnSelect'>Order</button>
";
}
?>
<?php
echo "<tr>
<td class='td-id'>".$row['id']."</td>
<td class='td-customer'>".$row['name']."</td>
$td_month
<td class='td-po'>".$row['po_number']."</td>
<td class='td-partnumber'>".$row['part_number']."</td>
<td class='td-partname'>".$row['part_name']."</td>
<td class='td-qtypcs'>".$row['qty']."</td>
$td_name
$ttl_kg
$ttl_kg1
$ttl_kg2
$ttl_kg3
</tr>";
}
?>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
result browser
only 1 id show and order resin (kg) now show
this code no use connection to db
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
table {width:100%;}
th {background-color: #4CAF50;color: white;}
table, th, td {border: 1px solid black;border-collapse: collapse;}
th, td {padding: 15px;text-align: left;}
table#t01 tr:nth-child(even) {background-color: #eee;}
table#t01 tr:nth-child(odd) {background-color: #fff;}
table#t01 th { background-color: black;color: white;}
.btnSelect {
background-color: #f44336;
border: 2px solid #f44336;
border-radius: 4px;
color: white;
cursor: pointer;
}
.btnSelect:hover{
background-color: #c93326; border: 2px solid #c93326;
}
</style>
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<tr>
<td class='td-id'>99</td>
<td class='td-customer'>ASMO</td>
<td rowspan='7' class='td-month'>December 2018</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-4-4</td>
<td class='td-partname'>ASMO4</td>
<td class='td-qtypcs'>1002</td>
<td rowspan='3' class='td-name'>DELRIN 111 PA (NC)</td>
<td rowspan='3' class='td-weighttotal'>74.511</td>
<td rowspan='3' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='3'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='3'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>101</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y1</td>
<td class='td-partname'>YAMAHA1</td>
<td class='td-qtypcs'>2000</td>
</tr><tr>
<td class='td-id'>103</td>
<td class='td-customer'>DENSO</td>
<td class='td-po'>DENSO1</td>
<td class='td-partnumber'>D1</td>
<td class='td-partname'>D1-11</td>
<td class='td-qtypcs'>3000</td>
</tr><tr>
<td class='td-id'>98</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-3-3</td>
<td class='td-partname'>ASMO3</td>
<td class='td-qtypcs'>1001</td>
<td rowspan='2' class='td-name'>DURACON M90-44 (NC)</td>
<td rowspan='2' class='td-weighttotal'>7.25425</td>
<td rowspan='2' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='2'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='2'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>97</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-2-2</td>
<td class='td-partname'>ASMO2</td>
<td class='td-qtypcs'>1000</td>
</tr><tr>
<td class='td-id'>100</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-5-5</td>
<td class='td-partname'>ASMO5</td>
<td class='td-qtypcs'>1003</td>
<td rowspan='1' class='td-name'>IUPILON S 3000 R (BK)</td>
<td rowspan='1' class='td-weighttotal'>28.209375</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>102</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y2</td>
<td class='td-partname'>YAMAHA2</td>
<td class='td-qtypcs'>2000</td>
<td rowspan='1' class='td-name'>LLDPE F-410 (NC)</td>
<td rowspan='1' class='td-weighttotal'>32.5</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
How to get value from "td" with dynamic rowspan ?
already tried but no lucky.
already read on
Jquery - get value of <td> tag that has rowspan more than one
How to get the table row td's value that has a row span column
, but no same case
help me
javascript php jquery mysql ajax
The td (obviously) belongs to some row. If you find the td you want isn't in the current row, then it's going to be in some row above the current row. So you need to loop through the previous rows in the table until you find the first row which contains it. That should be the value you need, I think.
– ADyson
Nov 22 at 14:36
@adyson , already tried , not working
– andry gusnardry
Nov 23 at 0:07
your current code doesn't show any attempt at all to do that. If you have an attempt to follow that logic, please show us, and explain what debugging you did and where you think it might be failing. "Not working" is not adequate as an explanation of your problem.
– ADyson
Nov 23 at 0:09
@ADyson , i.stack.imgur.com/BBo6C.png
– andry gusnardry
Nov 23 at 0:12
That's not code that's a picture
– ADyson
Nov 23 at 0:19
|
show 6 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<?php
$prevMonth = $prevPo = $prevDo = $prevKeyResin = "";
$rowspan=$total_kage=0;
$results = $conn->query("SELECT PCAP.id,MP.part_number,MP.part_name,M.name,MR.resin,PCAP.qty,PC.po_number,MP.cavity,MP.weight_product,MP.weight_runner,PC.month
,CONCAT (MR.resin) AS KeyResin
,CONCAT (DATE_FORMAT(PC.month,'%M %Y')) AS KeyMonth
,CONCAT (PC.po_number) AS KeyPo
,CONCAT (MR.resin) AS KeyName
FROM po_customer_add_product PCAP
LEFT JOIN po_customer PC ON PC.id=PCAP.po_customer_id
LEFT JOIN master_product MP ON MP.id=PCAP.product_id
LEFT JOIN master_resin MR ON MR.id=MP.material_name
LEFT JOIN master M ON M.id=PCAP.customer
Where PCAP.active='1' AND PCAP.open_po_resin='0'
Order BY PC.month ASC,MR.resin ASC ");
// fetch pertama, utk cari jumlah rowspan dan Total(Kg)
$rowspan = $rowname = $rowpo = $rowmon = $total_kage = 0;
$prevName = $prevPO = $prevMonth = $prevKeyResin = "";
$arrTotal = $arrRowSpan = array();
while($row = $results->fetch_array()) {
$pcapid = $row['id'];
$KeyName = $row['KeyName'];
if($KeyName!=$prevName) { $prevName=$KeyName; $rowname=1; } else { $rowname++; }
$arrRowSpan[$KeyName] = $rowname;
$KeyMonth = $row['KeyMonth'];
if($KeyMonth!=$prevMonth) { $prevMonth=$KeyMonth; $rowmon=1; } else { $rowmon++; }
$arrRowSpan[$KeyMonth] = $rowmon;
$KeyPo = $row['KeyPo'];
if($KeyPo!=$prevPo) { $prevPo=$KeyPo; $rowpo=1; } else { $rowpo++; }
$arrRowSpan[$KeyPo] = $rowpo;
$KeyResin = $row['KeyResin'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
if($KeyResin != $prevKeyResin) {
$prevKeyResin = $KeyResin;
$total_kage = $weighttotal;
$rowspan = 1;
} else {
$total_kage += $weighttotal;
$rowspan++;
}
$arrTotal[$KeyResin] = array( 'rowspan' => $rowspan, 'total_kage' => $total_kage );
}
$prevName = $prevPo = $prevMonth = $prevKeyResin = "";
$results->data_seek(0); // balikin lagi ke row[0]
while($row = $results->fetch_array()) {
$Name = $row['resin'];
$PO = $row['po_number'];
$Month = date('F Y',strtotime($row['month']));
$KeyName = $row['KeyName'];
$KeyMonth = $row['KeyMonth'];
$KeyResin = $row['KeyResin'];
$KeyPo = $row['KeyPo'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
$td_name = $td_month = $td_po = $ttl_kg = $ttl_kg1 = $ttl_kg2 = $ttl_kg3 = "";
if($KeyName!=$prevName) {
$prevName = $KeyName; $rowspan = $arrRowSpan[$KeyName];
$td_name = "<td rowspan='$rowspan' class='td-name'>$Name</td>";
}
if($KeyMonth!=$prevMonth) {
$prevMonth = $KeyMonth; $rowspan = $arrRowSpan[$KeyMonth];
$td_month = "<td rowspan='$rowspan' class='td-month'>$Month</td>";
}
if($KeyPo!=$prevPo) {
$prevPo = $KeyPo; $rowspan = $arrRowSpan[$KeyPo];
$td_po = "<td rowspan='$rowspan'>$PO</td>";
}
if($KeyResin != $prevKeyResin) {
$mulai = new DateTime($row['month']);
$mulai->add(new DateInterval('P1M'));
$sampe = new DateTime('+7 month');
$interval = new DateInterval('P1M');
$rangetgl = new DatePeriod($mulai, $interval ,$sampe);
$option = "";
foreach($rangetgl as $tgl){
$dateid = $tgl->format("Y-m");
$dateoption = $tgl->format("F Y");
$option .= "<option value='$dateid'>$dateoption</option>";
};
$prevKeyResin = $KeyResin;
$rowspan = $arrTotal[$KeyResin]['rowspan'];
$total_kage = $arrTotal[$KeyResin]['total_kage'];
$ttl_kg = "<td rowspan='$rowspan' class='td-weighttotal'>$total_kage</td>";
$ttl_kg1 = "<td rowspan='$rowspan' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
$option
</select>
</td>
";
$ttl_kg2 = "<td rowspan='$rowspan'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
";
$ttl_kg3 = "<td rowspan='$rowspan'><button class='btnSelect'>Order</button>
";
}
?>
<?php
echo "<tr>
<td class='td-id'>".$row['id']."</td>
<td class='td-customer'>".$row['name']."</td>
$td_month
<td class='td-po'>".$row['po_number']."</td>
<td class='td-partnumber'>".$row['part_number']."</td>
<td class='td-partname'>".$row['part_name']."</td>
<td class='td-qtypcs'>".$row['qty']."</td>
$td_name
$ttl_kg
$ttl_kg1
$ttl_kg2
$ttl_kg3
</tr>";
}
?>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
result browser
only 1 id show and order resin (kg) now show
this code no use connection to db
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
table {width:100%;}
th {background-color: #4CAF50;color: white;}
table, th, td {border: 1px solid black;border-collapse: collapse;}
th, td {padding: 15px;text-align: left;}
table#t01 tr:nth-child(even) {background-color: #eee;}
table#t01 tr:nth-child(odd) {background-color: #fff;}
table#t01 th { background-color: black;color: white;}
.btnSelect {
background-color: #f44336;
border: 2px solid #f44336;
border-radius: 4px;
color: white;
cursor: pointer;
}
.btnSelect:hover{
background-color: #c93326; border: 2px solid #c93326;
}
</style>
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<tr>
<td class='td-id'>99</td>
<td class='td-customer'>ASMO</td>
<td rowspan='7' class='td-month'>December 2018</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-4-4</td>
<td class='td-partname'>ASMO4</td>
<td class='td-qtypcs'>1002</td>
<td rowspan='3' class='td-name'>DELRIN 111 PA (NC)</td>
<td rowspan='3' class='td-weighttotal'>74.511</td>
<td rowspan='3' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='3'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='3'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>101</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y1</td>
<td class='td-partname'>YAMAHA1</td>
<td class='td-qtypcs'>2000</td>
</tr><tr>
<td class='td-id'>103</td>
<td class='td-customer'>DENSO</td>
<td class='td-po'>DENSO1</td>
<td class='td-partnumber'>D1</td>
<td class='td-partname'>D1-11</td>
<td class='td-qtypcs'>3000</td>
</tr><tr>
<td class='td-id'>98</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-3-3</td>
<td class='td-partname'>ASMO3</td>
<td class='td-qtypcs'>1001</td>
<td rowspan='2' class='td-name'>DURACON M90-44 (NC)</td>
<td rowspan='2' class='td-weighttotal'>7.25425</td>
<td rowspan='2' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='2'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='2'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>97</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-2-2</td>
<td class='td-partname'>ASMO2</td>
<td class='td-qtypcs'>1000</td>
</tr><tr>
<td class='td-id'>100</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-5-5</td>
<td class='td-partname'>ASMO5</td>
<td class='td-qtypcs'>1003</td>
<td rowspan='1' class='td-name'>IUPILON S 3000 R (BK)</td>
<td rowspan='1' class='td-weighttotal'>28.209375</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>102</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y2</td>
<td class='td-partname'>YAMAHA2</td>
<td class='td-qtypcs'>2000</td>
<td rowspan='1' class='td-name'>LLDPE F-410 (NC)</td>
<td rowspan='1' class='td-weighttotal'>32.5</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
How to get value from "td" with dynamic rowspan ?
already tried but no lucky.
already read on
Jquery - get value of <td> tag that has rowspan more than one
How to get the table row td's value that has a row span column
, but no same case
help me
javascript php jquery mysql ajax
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<?php
$prevMonth = $prevPo = $prevDo = $prevKeyResin = "";
$rowspan=$total_kage=0;
$results = $conn->query("SELECT PCAP.id,MP.part_number,MP.part_name,M.name,MR.resin,PCAP.qty,PC.po_number,MP.cavity,MP.weight_product,MP.weight_runner,PC.month
,CONCAT (MR.resin) AS KeyResin
,CONCAT (DATE_FORMAT(PC.month,'%M %Y')) AS KeyMonth
,CONCAT (PC.po_number) AS KeyPo
,CONCAT (MR.resin) AS KeyName
FROM po_customer_add_product PCAP
LEFT JOIN po_customer PC ON PC.id=PCAP.po_customer_id
LEFT JOIN master_product MP ON MP.id=PCAP.product_id
LEFT JOIN master_resin MR ON MR.id=MP.material_name
LEFT JOIN master M ON M.id=PCAP.customer
Where PCAP.active='1' AND PCAP.open_po_resin='0'
Order BY PC.month ASC,MR.resin ASC ");
// fetch pertama, utk cari jumlah rowspan dan Total(Kg)
$rowspan = $rowname = $rowpo = $rowmon = $total_kage = 0;
$prevName = $prevPO = $prevMonth = $prevKeyResin = "";
$arrTotal = $arrRowSpan = array();
while($row = $results->fetch_array()) {
$pcapid = $row['id'];
$KeyName = $row['KeyName'];
if($KeyName!=$prevName) { $prevName=$KeyName; $rowname=1; } else { $rowname++; }
$arrRowSpan[$KeyName] = $rowname;
$KeyMonth = $row['KeyMonth'];
if($KeyMonth!=$prevMonth) { $prevMonth=$KeyMonth; $rowmon=1; } else { $rowmon++; }
$arrRowSpan[$KeyMonth] = $rowmon;
$KeyPo = $row['KeyPo'];
if($KeyPo!=$prevPo) { $prevPo=$KeyPo; $rowpo=1; } else { $rowpo++; }
$arrRowSpan[$KeyPo] = $rowpo;
$KeyResin = $row['KeyResin'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
if($KeyResin != $prevKeyResin) {
$prevKeyResin = $KeyResin;
$total_kage = $weighttotal;
$rowspan = 1;
} else {
$total_kage += $weighttotal;
$rowspan++;
}
$arrTotal[$KeyResin] = array( 'rowspan' => $rowspan, 'total_kage' => $total_kage );
}
$prevName = $prevPo = $prevMonth = $prevKeyResin = "";
$results->data_seek(0); // balikin lagi ke row[0]
while($row = $results->fetch_array()) {
$Name = $row['resin'];
$PO = $row['po_number'];
$Month = date('F Y',strtotime($row['month']));
$KeyName = $row['KeyName'];
$KeyMonth = $row['KeyMonth'];
$KeyResin = $row['KeyResin'];
$KeyPo = $row['KeyPo'];
$hasilshot = $row['qty']/$row['cavity'];
$weight1shot = ($row['weight_product']*$row['cavity'])+($row['weight_runner']);
$weighttotal = ($weight1shot*$hasilshot)/1000;
$td_name = $td_month = $td_po = $ttl_kg = $ttl_kg1 = $ttl_kg2 = $ttl_kg3 = "";
if($KeyName!=$prevName) {
$prevName = $KeyName; $rowspan = $arrRowSpan[$KeyName];
$td_name = "<td rowspan='$rowspan' class='td-name'>$Name</td>";
}
if($KeyMonth!=$prevMonth) {
$prevMonth = $KeyMonth; $rowspan = $arrRowSpan[$KeyMonth];
$td_month = "<td rowspan='$rowspan' class='td-month'>$Month</td>";
}
if($KeyPo!=$prevPo) {
$prevPo = $KeyPo; $rowspan = $arrRowSpan[$KeyPo];
$td_po = "<td rowspan='$rowspan'>$PO</td>";
}
if($KeyResin != $prevKeyResin) {
$mulai = new DateTime($row['month']);
$mulai->add(new DateInterval('P1M'));
$sampe = new DateTime('+7 month');
$interval = new DateInterval('P1M');
$rangetgl = new DatePeriod($mulai, $interval ,$sampe);
$option = "";
foreach($rangetgl as $tgl){
$dateid = $tgl->format("Y-m");
$dateoption = $tgl->format("F Y");
$option .= "<option value='$dateid'>$dateoption</option>";
};
$prevKeyResin = $KeyResin;
$rowspan = $arrTotal[$KeyResin]['rowspan'];
$total_kage = $arrTotal[$KeyResin]['total_kage'];
$ttl_kg = "<td rowspan='$rowspan' class='td-weighttotal'>$total_kage</td>";
$ttl_kg1 = "<td rowspan='$rowspan' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
$option
</select>
</td>
";
$ttl_kg2 = "<td rowspan='$rowspan'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
";
$ttl_kg3 = "<td rowspan='$rowspan'><button class='btnSelect'>Order</button>
";
}
?>
<?php
echo "<tr>
<td class='td-id'>".$row['id']."</td>
<td class='td-customer'>".$row['name']."</td>
$td_month
<td class='td-po'>".$row['po_number']."</td>
<td class='td-partnumber'>".$row['part_number']."</td>
<td class='td-partname'>".$row['part_name']."</td>
<td class='td-qtypcs'>".$row['qty']."</td>
$td_name
$ttl_kg
$ttl_kg1
$ttl_kg2
$ttl_kg3
</tr>";
}
?>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
result browser
only 1 id show and order resin (kg) now show
this code no use connection to db
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
table {width:100%;}
th {background-color: #4CAF50;color: white;}
table, th, td {border: 1px solid black;border-collapse: collapse;}
th, td {padding: 15px;text-align: left;}
table#t01 tr:nth-child(even) {background-color: #eee;}
table#t01 tr:nth-child(odd) {background-color: #fff;}
table#t01 th { background-color: black;color: white;}
.btnSelect {
background-color: #f44336;
border: 2px solid #f44336;
border-radius: 4px;
color: white;
cursor: pointer;
}
.btnSelect:hover{
background-color: #c93326; border: 2px solid #c93326;
}
</style>
<div class="container">
<form action="" method="post">
<h4 class="title">REQUEST RESIN BASED ON PO CUSTOMER</h4>
<table>
<tr>
<th>Id</th>
<th>Customer</th>
<th>Month</th>
<th>PO Number</th>
<th>Part Number</th>
<th>Part Name</th>
<th>Qty Pcs</th>
<th>Material Name</th>
<th>weight Product (Kg)</th>
<th>Order Month</th>
<th>Order Resin (Kg)</th>
<th>Save Order</th>
</tr>
<tr>
<td class='td-id'>99</td>
<td class='td-customer'>ASMO</td>
<td rowspan='7' class='td-month'>December 2018</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-4-4</td>
<td class='td-partname'>ASMO4</td>
<td class='td-qtypcs'>1002</td>
<td rowspan='3' class='td-name'>DELRIN 111 PA (NC)</td>
<td rowspan='3' class='td-weighttotal'>74.511</td>
<td rowspan='3' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='3'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='3'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>101</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y1</td>
<td class='td-partname'>YAMAHA1</td>
<td class='td-qtypcs'>2000</td>
</tr><tr>
<td class='td-id'>103</td>
<td class='td-customer'>DENSO</td>
<td class='td-po'>DENSO1</td>
<td class='td-partnumber'>D1</td>
<td class='td-partname'>D1-11</td>
<td class='td-qtypcs'>3000</td>
</tr><tr>
<td class='td-id'>98</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-3-3</td>
<td class='td-partname'>ASMO3</td>
<td class='td-qtypcs'>1001</td>
<td rowspan='2' class='td-name'>DURACON M90-44 (NC)</td>
<td rowspan='2' class='td-weighttotal'>7.25425</td>
<td rowspan='2' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='2'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='2'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>97</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-2-2</td>
<td class='td-partname'>ASMO2</td>
<td class='td-qtypcs'>1000</td>
</tr><tr>
<td class='td-id'>100</td>
<td class='td-customer'>ASMO</td>
<td class='td-po'>ASMO1</td>
<td class='td-partnumber'>ASMO-5-5</td>
<td class='td-partname'>ASMO5</td>
<td class='td-qtypcs'>1003</td>
<td rowspan='1' class='td-name'>IUPILON S 3000 R (BK)</td>
<td rowspan='1' class='td-weighttotal'>28.209375</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr><tr>
<td class='td-id'>102</td>
<td class='td-customer'>YAMAHA</td>
<td class='td-po'>YAMAHA1</td>
<td class='td-partnumber'>Y2</td>
<td class='td-partname'>YAMAHA2</td>
<td class='td-qtypcs'>2000</td>
<td rowspan='1' class='td-name'>LLDPE F-410 (NC)</td>
<td rowspan='1' class='td-weighttotal'>32.5</td>
<td rowspan='1' class='td-poorderresin'>
<select name='pomonth' class='select-field9' required>
<option value='0'>Choose Month</option>
<option value='2019-01'>January 2019</option><option value='2019-02'>February 2019</option><option value='2019-03'>March 2019</option><option value='2019-04'>April 2019</option><option value='2019-05'>May 2019</option><option value='2019-06'>June 2019</option>
</select>
</td>
<td rowspan='1'>
<input type='text' required class='input-field9' autocomplete='off' name='qtyorder' onkeypress='return onlyNumbers(event);' maxlength='6' onkeyup='oneDot(this)'/>
<input type='hidden' name='unique' value='mrp_order_resin' readonly='readonly' required />
</td>
<td rowspan='1'><button class='btnSelect'>Order</button>
</tr>
</table>
<div class="clearfix">
</div>
<div class="mid-popular">
</div>
</form>
</div>
<script>
//*
$(document).ready(function(){
$(".btnSelect").on('click',function(){
// get the current row
var currentRow = $(this).closest("tr");
var col1 = currentRow.find(".td-id").html();
var col2 = currentRow.find(".td-customer").html();
var col3 = currentRow.find(".td-month").html();
var col4 = currentRow.find(".td-po").html();
var col5 = currentRow.find(".td-partnumber").html();
var col6 = currentRow.find(".td-partname").html();
var col7 = currentRow.find(".td-qtypcs").html();
var col8 = currentRow.find(".td-name").html();
var col9 = currentRow.find(".td-weighttotal").html();
var col10 = currentRow.find(":selected").html();
var col11 = currentRow.find("input[name='qtyorder']").html();
var data = col1 + "n" + col2 + "n" + col3 + "n" + col4 + "n" + col5 + "n" + col6 + "n" + col7 + "n" + col8 + "n" + col9 + "n" + col10 + "n" + col11;
alert(data);
});
});
//*
</script>
How to get value from "td" with dynamic rowspan ?
already tried but no lucky.
already read on
Jquery - get value of <td> tag that has rowspan more than one
How to get the table row td's value that has a row span column
, but no same case
help me
javascript php jquery mysql ajax
javascript php jquery mysql ajax
edited Nov 23 at 5:48
asked Nov 22 at 13:59
andry gusnardry
34
34
The td (obviously) belongs to some row. If you find the td you want isn't in the current row, then it's going to be in some row above the current row. So you need to loop through the previous rows in the table until you find the first row which contains it. That should be the value you need, I think.
– ADyson
Nov 22 at 14:36
@adyson , already tried , not working
– andry gusnardry
Nov 23 at 0:07
your current code doesn't show any attempt at all to do that. If you have an attempt to follow that logic, please show us, and explain what debugging you did and where you think it might be failing. "Not working" is not adequate as an explanation of your problem.
– ADyson
Nov 23 at 0:09
@ADyson , i.stack.imgur.com/BBo6C.png
– andry gusnardry
Nov 23 at 0:12
That's not code that's a picture
– ADyson
Nov 23 at 0:19
|
show 6 more comments
The td (obviously) belongs to some row. If you find the td you want isn't in the current row, then it's going to be in some row above the current row. So you need to loop through the previous rows in the table until you find the first row which contains it. That should be the value you need, I think.
– ADyson
Nov 22 at 14:36
@adyson , already tried , not working
– andry gusnardry
Nov 23 at 0:07
your current code doesn't show any attempt at all to do that. If you have an attempt to follow that logic, please show us, and explain what debugging you did and where you think it might be failing. "Not working" is not adequate as an explanation of your problem.
– ADyson
Nov 23 at 0:09
@ADyson , i.stack.imgur.com/BBo6C.png
– andry gusnardry
Nov 23 at 0:12
That's not code that's a picture
– ADyson
Nov 23 at 0:19
The td (obviously) belongs to some row. If you find the td you want isn't in the current row, then it's going to be in some row above the current row. So you need to loop through the previous rows in the table until you find the first row which contains it. That should be the value you need, I think.
– ADyson
Nov 22 at 14:36
The td (obviously) belongs to some row. If you find the td you want isn't in the current row, then it's going to be in some row above the current row. So you need to loop through the previous rows in the table until you find the first row which contains it. That should be the value you need, I think.
– ADyson
Nov 22 at 14:36
@adyson , already tried , not working
– andry gusnardry
Nov 23 at 0:07
@adyson , already tried , not working
– andry gusnardry
Nov 23 at 0:07
your current code doesn't show any attempt at all to do that. If you have an attempt to follow that logic, please show us, and explain what debugging you did and where you think it might be failing. "Not working" is not adequate as an explanation of your problem.
– ADyson
Nov 23 at 0:09
your current code doesn't show any attempt at all to do that. If you have an attempt to follow that logic, please show us, and explain what debugging you did and where you think it might be failing. "Not working" is not adequate as an explanation of your problem.
– ADyson
Nov 23 at 0:09
@ADyson , i.stack.imgur.com/BBo6C.png
– andry gusnardry
Nov 23 at 0:12
@ADyson , i.stack.imgur.com/BBo6C.png
– andry gusnardry
Nov 23 at 0:12
That's not code that's a picture
– ADyson
Nov 23 at 0:19
That's not code that's a picture
– ADyson
Nov 23 at 0:19
|
show 6 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432612%2fhow-to-get-data-value-from-td-with-dynamic-rowspan%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The td (obviously) belongs to some row. If you find the td you want isn't in the current row, then it's going to be in some row above the current row. So you need to loop through the previous rows in the table until you find the first row which contains it. That should be the value you need, I think.
– ADyson
Nov 22 at 14:36
@adyson , already tried , not working
– andry gusnardry
Nov 23 at 0:07
your current code doesn't show any attempt at all to do that. If you have an attempt to follow that logic, please show us, and explain what debugging you did and where you think it might be failing. "Not working" is not adequate as an explanation of your problem.
– ADyson
Nov 23 at 0:09
@ADyson , i.stack.imgur.com/BBo6C.png
– andry gusnardry
Nov 23 at 0:12
That's not code that's a picture
– ADyson
Nov 23 at 0:19