here is my whole code:
Code:
<?php
error_reporting(0);
date_default_timezone_set("Asia/Singapore"); //set the time zone
$con = mysql_connect('localhost', 'root','');
if (!$con) {
echo 'failed';
die();
}
mysql_select_db("mes", $con);
?>
<html>
<title>Stock Requisition</title>
<head>
<link rel="stylesheet" type="text/css" href="kanban.css">
<script type="text/javascript">
function save_sr(){
var SubQty = document.getElementsById("joinId").value;
}
</script>
<script type="text/javascript">
function test_(cmpd) {
var len_ = (document.frmMain.elements.length) - 1;
for (i=0; i <= len_; i++ ) {
var strPos_ = document.frmMain.elements[i].id.indexOf(cmpd)
if (strPos_ != -1) {
var strPos = document.frmMain.elements[i].id.indexOf("_");
var strId = document.frmMain.elements[i].id.slice(strPos + 1) + "_" + document.frmMain.elements[i].id.slice(0,strPos)
document.frmMain.elements[i].value = Math.round((document.getElementById(strId).value * document.getElementById('DemandedQty').value) * 100 ) / 100;
}
}
}
</script>
</head>
<body>
<form name="frmMain" method="post">
<div>
<table>
<thead>
<th>Items</th>
<th>Sub Items</th>
<th>Item Code</th>
<th>Demanded Qty</th>
<th>UoM</th>
<th>Class</th>
<th>Description</th>
<th>BIN Location</th>
</thead>
<?php
$DemandedQty = $_POST['DemandedQty'];
$sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items";
$res_bom = mysql_query($sql, $con);
while($row = mysql_fetch_assoc($res_bom)){
$Items = $row['Items'];
$Items_ = substr($Items, 12, 3);
echo "<tr>
<td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items_' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>
<td style='border:none;'> </td>
<td style='border:none;'> </td>
<td style='border: none;'><center><input type='text' style='text-align: right;' name='DemandedQty[]' id='DemandedQty' size='12' onkeyup='test_(\"$Items_\")'></center></td>
</tr>";
$sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error());
$res_sub = mysql_query($sql, $con);
$counter = 0;
while($row_sub = mysql_fetch_assoc($res_sub)){
$joinId = $counter . "_" . $Items_;
$Items = $row_sub['Items'];
$Items1 = substr($Items, 12, 3);
$SubItems = $row_sub['SubItems'];
$ItemCode = $row_sub['ItemCode'];
$UoM = $row_sub['UoM'];
$Class = $row_sub['Class'];
$Description = $row_sub['Description'];
$BINLocation = $row_sub['BINLocation'];
$Quantity = $row_sub['Quantity'];
$joinId2 = $Items_ . "_" . $counter;
echo "<tr>
<td style='border: none;'> <input type='hidden' value='$Items1' name='Items1[]' id='Items1'></td>
<td style='border: none;'> <input type='text' name='SubItems[]' id='SubItems' value='$SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>
<td style='border: none;'> <input type='text' name='ItemCode[]' id='ItemCode' value='$ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>
<td><input class='txt' type='text' name='SubQty[]' id='$joinId' size='12' style= 'border:none;'/><input type='hidden' id='$joinId2' value='$Quantity' /></td>
<td style='border: none;' size='3'> <input type='text' name='UoM[]' id='UoM' value='$UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td>
<td style='border: none;'> <input type='text' name='Class[]' value='$Class' name='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>
<td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td>
<td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>
</tr>";
$counter = $counter + 1;
}
}
?>
</table>
</div>
<div id="save_btn">
<input type="button" name="button" value="save" onClick="save_sr()" style="width: 5em;">
</div>
</form>
</body>
</html>
Thank you
Bookmarks