PDA

View Full Version : Auto calculate conversion and display beside textbox



newphpbees
06 Mar 2012, 07:14 PM
Hi..

I have syntax for autocalculate the max lot and the output display in Total_max same with min lot and the output display in Totam_min, now I need to have convert automatically the number I was inputted in max lot textbox and it will display in max doz textbox same also with min lot convert to min doz textbox.

the conversion is:

max doz = max lot * 10
min doz = min lot * 10

here is my code:



<html>
<head>
<link rel="stylesheet" type="text/css" href="kanban.css" />
<script type="text/javascript">

function display_PS(){
document.loading_kanban.action="ParameterSettings.php";
document.loading_kanban.submit();
}
function display_Kanban(){
document.loading_kanban.action="kanban_report.php";
document.loading_kanban.submit();
}
</script>

<script type="text/javascript">
//Code for auto calculate Total Max//
function autocalearn(oText)
{
if (isNaN(oText.value)) //filter input
{
alert('Numbers only!');
oText.value = '';
}
var field, val, oForm = oText.form, Total_max = a = 0;
for (a; a < arguments.length; ++a) //loop through text elements
{
field = arguments[a];
val = parseFloat(field.value);
if (!isNaN(val)) //number?
{
Total_max += val; //accumulate
}
}
oForm.Total_max.value = Total_max.toFixed(2);
}

</script>


<script type="text/javascript">
//Code for auto calculate Total Min//
function autocalmin(oText)
{
if (isNaN(oText.value)) //filter input
{
alert('Numbers only!');
oText.value = '';
}
var field, val, oForm = oText.form, Total_min = a = 0;
for (a; a < arguments.length; ++a) //loop through text elements
{
field = arguments[a];
val = parseFloat(field.value); //get value
if (!isNaN(val)) //number?
{
Total_min += val; //accumulate
}
}

oForm.Total_min.value = Total_min.toFixed(2); //out
}

</script>
</head>
<form name="loading_kanban">
<div id="main_button">
<center>
<!--<label style="margin-left: .9em; font-family: Arial, Helvetica, sans-serif; font-size: .7em;">Display Details:</label><input onclick='showDetails(this);' id='chkDetail' type='checkbox' checked='checked' value='wip'/> -->
<input type="button" name="parameter_settings" value="Parameter Settings" onclick="display_PS()">
<input type="button" name="parameter_settings" value="Stock Requisition">
<input type="button" name="parameter_settings" value="Kanban Report" onclick="display_Kanban()">
</center>
</div>
<div id="fieldset_PS">
<center>
<table border="1">
<th>Compounds</th>
<th>Max</th>
<th>UOM</th>
<th>Max</th>
<th>UOM</th>
<th>Min</th>
<th>UOM</th>
<th>Min</th>
<th>UOM</th>

<tr>
<td><label id="P27" name="P27" size="6" style="text-align: center;">P27</label></td>
<td><input type="text" name="P27_max" id="P27_max" size="6" onkeyup="return autocalearn(this, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P27LOT_max" name="P27LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P27_maxdoz" id="P27_maxdoz" size="6"></td>
<td><label id="P27Doz_max" name="P27Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P27_min" id="P27_min" size="6" onkeyup="return autocalmin(this, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P27LOT_min" name="P27LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P27_mindoz" id="P27_mindoz" size="6"></td>
<td><label id="P27Doz_min" name="P27Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P28" name="P28" size="6">P28</label></td>
<td><input type="text" name="P28_max" id="P28_max" size="6" onkeyup="return autocalearn(this, P27_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P28LOT_max" name="P28LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P28_maxdoz" id="P28_maxdoz" size="6"></td>
<td><label id="P28Doz_max" name="P28Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P28_min" id="P28_min" size="6" onkeyup="return autocalmin(this, P27_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P28LOT_min" name="P28LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P28_mindoz" id="P28_mindoz" size="6"></td>
<td><label id="P28Doz_min" name="P28Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P30" name="P30" size="6">P30</label></td>
<td><input type="text" name="P30_max" id="P30_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P30LOT_max" name="P30LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P30_maxdoz" id="P30_maxdoz" size="6"></td>
<td><label id="P30Doz_max" name="P30Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P30_min" id="P30_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P30LOT_min" name="P30LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P30_mindoz" id="P30_mindoz" size="6"></td>
<td><label id="P30Doz_min" name="P30Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P32W" name="P32W" size="6">P32W</label></td>
<td><input type="text" name="P32W_max" id="P32W_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P32WLOT_max" name="P32WLOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P32W_maxdoz" id="P32W_maxdoz" size="6"></td>
<td><label id="P32WDoz_max" name="P32WDoz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P32W_min" id="P32W_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P32WLot_min" name="P32WLot_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P32W_mindoz" id="P32W_mindoz" size="6"></td>
<td><label id="P32WDoz_min" name="P32WDoz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P33" name="P33" size="6">P33</label></td>
<td><input type="text" name="P33_max" id="P33_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P33LOT_max" name="P33LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P33_maxdoz" id="P33_maxdoz" size="6"></td>
<td><label id="P33Doz_max" name="P33Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P33_min" id="P33_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P33LOT_min" name="P33LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P33_mindoz" id="P33_mindoz" size="6"></td>
<td><label id="P33Doz_min" name="P33Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P35" name="P35" size="6">P35</label></td>
<td><input type="text" name="P35_max" id="P35_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P35LOT_max" name="P35LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P35_maxdoz" id="P35_maxdoz" size="6"></td>
<td><label id="P35Doz_max" name="P35Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P35_min" id="P35_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P35LOT_min" name="P35LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P35_mindoz" id="P35_mindoz" size="6"></td>
<td><label id="P35Doz_min" name="P35Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="Total" name="Total" size="6"><b>Total</b><label></td>
<td><input type="text" name="Total_max" id="Total_max" size="6"></td>
<td><label id="TotalLOT_max" name="TotalLOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="Total_maxdoz" id="Total_maxdoz" size="6"></td>
<td><label id="TotalDoz_max" name="TotalDoz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="Total_min" id="Total_min" size="6"></td>
<td><label id="TotalLOT_min" name="TotalLOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="Total_mindoz" id="Total_mindoz" size="6"></td>
<td><label id="TotalDoz_min" name="TotalDoz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
</table>
</center>
</form>
</html>


I attach the sample imge of my webpage.