...

View Full Version : Auto calculate conversion and display to beside textbox



newphpcoder
03-07-2012, 01:09 AM
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); //get value
if (!isNaN(val)) //number?
{
Total_max += val; //accumulate
}
}
oForm.Total_max.value = Total_max.toFixed(2); //out
}

</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="P35M" name="P35M" size="6">P35M</label></td>
<td><input type="text" name="P35M_max" id="P35M_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P35MLOT_max" name="P35MLOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P35M_maxdoz" id="P35M_maxdoz" size="6"></td>
<td><label id="P35MDoz_max" name="P35MDoz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P35M_min" id="P35M_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P35MLOT_min" name="P35MLOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P35M_mindoz" id="P35M_mindoz" size="6"></td>
<td><label id="P35MDoz_min" name="P35MDoz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P35W" name="P35W" size="6">P35W</label></td>
<td><input type="text" name="P35W_max" id="P35W_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P35WLOT_max" name="P35WLOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P35W_maxdoz" id="P35W_maxdoz" size="6"></td>
<td><label id="P35WDoz_max" name="P35WDoz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P35W_min" id="P35W_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P35WLOT_min" name="P35WLOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P35W_mindoz" id="P35W_mindoz" size="6"></td>
<td><label id="P35WDoz_min" name="P35WDoz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P38" name="P38" size="6">P38</label></td>
<td><input type="text" name="P38_max" id="P38_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P38LOT_max" name="P38LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P38_maxdoz" id="P38_maxdoz" size="6"></td>
<td><label id="P38Doz_max" name="P38Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P38_min" id="P38_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P38LOT_min" name="P38LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P38_mindoz" id="P38_mindoz" size="6"></td>
<td><label id="P38Doz_min" name="P38Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>
<tr>
<td><label id="P41" name="P41" size="6">P41</label></td>
<td><input type="text" name="P41_max" id="P41_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P41LOT_max" name="P41LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P41_maxdoz" id="P41_maxdoz" size="6"></td>
<td><label id="P41Doz_max" name="P41Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P41_min" id="P41_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P41LOT_min" name="P41LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P41_mindoz" id="P41_mindoz" size="6"></td>
<td><label id="P41Doz_min" name="P41Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>

<tr>
<td><label id="P42" name="P42" size="6">P42</label></td>
<td><input type="text" name="P42_max" id="P42_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P43_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P42LOT_max" name="P42LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P42_maxdoz" id="P42_maxdoz" size="6"></td>
<td><label id="P42Doz_max" name="P42Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P42_min" id="P42_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P43_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P42LOT_min" name="P42LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P42_mindoz" id="P42_mindoz" size="6"></td>
<td><label id="P42Doz_min" name="P42Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>

<tr>
<td><label id="P43" name="P43" size="6">P43</label></td>
<td><input type="text" name="P43_max" id="P43_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P45_max, P46_max, P47_max)"></td>
<td><label id="P43LOT_max" name="P43LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P43_maxdoz" id="P43_maxdoz" size="6"></td>
<td><label id="P43Doz_max" name="P43Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P43_min" id="P43_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P45_min, P46_min, P47_min)"></td>
<td><label id="P43LOT_min" name="P43LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P43_mindoz" id="P43_mindoz" size="6"></td>
<td><label id="P43Doz_min" name="P43Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>

<tr>
<td><label id="P45" name="P45" size="6">P45</label></td>
<td><input type="text" name="P45_max" id="P45_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P46_max, P47_max)"></td>
<td><label id="P45LOT_max" name="P45LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P45_maxdoz" id="P45_maxdoz" size="6"></td>
<td><label id="P45Doz_max" name="P45Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P45_min" id="P45_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P46_min, P47_min)"></td>
<td><label id="P45LOT_min" name="P45LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P45_mindoz" id="P45_mindoz" size="6"></td>
<td><label id="P45Doz_min" name="P45Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>

<tr>
<td><label id="P46" name="P46" size="6">P46</label></td>
<td><input type="text" name="P46_max" id="P46_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P47_max)"></td>
<td><label id="P46LOT_max" name="P46LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P46_maxdoz" id="P46_maxdoz" size="6"></td>
<td><label id="P46Doz_max" name="P46Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P46_min" id="P46_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P47_min)"></td>
<td><label id="P46LOT_min" name="P46LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P46_mindoz" id="P46_mindoz" size="6"></td>
<td><label id="P46Doz_min" name="P46Doz_min" size="3" style="text-align: left;">Doz</label></td>
</tr>

<tr>
<td><label id="P47" name="P47" size="6">P47</label></td>
<td><input type="text" name="P47_max" id="P47_max" size="6" onkeyup="return autocalearn(this, P27_max, 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)"></td>
<td><label id="P47LOT_max" name="P47LOT_max" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P47_maxdoz" id="P47_maxdoz" size="6"></td>
<td><label id="P47Doz_max" name="P47Doz_max" size="3" style="text-align: left;">Doz</label></td>
<td><input type="text" name="P47_min" id="P47_min" size="6" onkeyup="return autocalmin(this, P27_min, 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)"></td>
<td><label id="P47LOT_min" name="P47LOT_min" size="3" style="text-align: left;">Lot</label></td>
<td><input type="text" name="P47_mindoz" id="P47_mindoz" size="6"></td>
<td><label id="P47Doz_min" name="P47Doz_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>
</div>
<div id="footer_button">
<input type="button" name="SAVE" value="SAVE" style="width: 25%;">
<input type="button" name="CANCEL" value="CANCEL">
</div>
</form>
</html>


I attach the sample imge of my webpage.

jmrker
03-07-2012, 05:55 AM
I'm not sure I understand the conversion logic with the * 10 changes.
However, this might be easier to figure out where you want this change
if you have a lot less code to modify.

See if this makes sense to you. If not, explain a bit more about the * 10 calculations.



<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">
function autocal(oText) {
if (isNaN(oText.value)) { alert('Numbers only!'); oText.value = ''; return ''; } //filter input
var field, val, Total = a = 0;
for (a; a < arguments.length; ++a) { //loop through text elements
field = arguments[a];
val = parseFloat(field.value); //get value
if (!isNaN(val)) { Total += val; } // if number? then accumulate
}
return Total.toFixed(2);
}

</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>
<script type="text/javascript">
var Compounds = ['P27','P28','P30','P32W','P33','P35','P35M','P35W','P38','P41','P42','P43','P45','P46','P47'];
var str = '';
for (var i=0; i<Compounds.length; i++) {
str += '<tr>';
str += '<td><label id="'+Compounds[i]+'" ';
str += 'name="'+Compounds[i]+'" ';
str += 'size="6" style="text-align:center;">'+Compounds[i]+'</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_max" ';
str += 'id="'+Compounds[i]+'_max" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_max\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_max'; }
}
str += ')"></td>';

str += '<td><label id="'+Compounds[i]+'LOT_max" ';
str += 'name="'+Compounds[i]+'LOT_max" ';
str += 'size="3" style="text-align:left;">Lot</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_maxdoz" ';
str += 'id="'+Compounds[i]+'_maxdoz" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_maxdoz\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_maxdoz'; }
}
str += ')*10"></td>';

str += '<td><label id="'+Compounds[i]+'Doz_max" ';
str += 'name="'+Compounds[i]+'Doz_max" ';
str += 'size="3" style="text-align:left;">Doz</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_min" ';
str += 'id="'+Compounds[i]+'_min" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_min\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_min'; }
}
str += ')"></td>';

str += '<td><label id="'+Compounds[i]+'LOT_min" ';
str += 'name="'+Compounds[i]+'LOT_min" ';
str += 'size="3" style="text-align:left;">Lot</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_mindoz" ';
str += 'id="'+Compounds[i]+'_mindoz" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_mindoz\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_mindoz'; }
}
str += ')*10"></td>';

str += '<td><label id="'+Compounds[i]+'Doz_min" ';
str += 'name="'+Compounds[i]+'Doz_min" ';
str += 'size="3" style="text-align:left;">Doz</label>';
str += '</td>';

str += '</tr>';
}
document.write(str);
</script>

<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>
</div>
<div id="footer_button">
<center>
<input type="button" name="SAVE" value="SAVE" style="width: 25%;">
<input type="button" name="CANCEL" value="CANCEL">
</center>
</div>
</form>
</html>

Can't really tell how it looks formatted as you neglected to include the css file contents.
:eek:

newphpcoder
03-07-2012, 06:19 AM
I'm not sure I understand the conversion logic with the * 10 changes.
However, this might be easier to figure out where you want this change
if you have a lot less code to modify.

See if this makes sense to you. If not, explain a bit more about the * 10 calculations.



<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">
function autocal(oText) {
if (isNaN(oText.value)) { alert('Numbers only!'); oText.value = ''; return ''; } //filter input
var field, val, Total = a = 0;
for (a; a < arguments.length; ++a) { //loop through text elements
field = arguments[a];
val = parseFloat(field.value); //get value
if (!isNaN(val)) { Total += val; } // if number? then accumulate
}
return Total.toFixed(2);
}

</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>
<script type="text/javascript">
var Compounds = ['P27','P28','P30','P32W','P33','P35','P35M','P35W','P38','P41','P42','P43','P45','P46','P47'];
var str = '';
for (var i=0; i<Compounds.length; i++) {
str += '<tr>';
str += '<td><label id="'+Compounds[i]+'" ';
str += 'name="'+Compounds[i]+'" ';
str += 'size="6" style="text-align:center;">'+Compounds[i]+'</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_max" ';
str += 'id="'+Compounds[i]+'_max" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_max\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_max'; }
}
str += ')"></td>';

str += '<td><label id="'+Compounds[i]+'LOT_max" ';
str += 'name="'+Compounds[i]+'LOT_max" ';
str += 'size="3" style="text-align:left;">Lot</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_maxdoz" ';
str += 'id="'+Compounds[i]+'_maxdoz" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_maxdoz\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_maxdoz'; }
}
str += ')*10"></td>';

str += '<td><label id="'+Compounds[i]+'Doz_max" ';
str += 'name="'+Compounds[i]+'Doz_max" ';
str += 'size="3" style="text-align:left;">Doz</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_min" ';
str += 'id="'+Compounds[i]+'_min" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_min\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_min'; }
}
str += ')"></td>';

str += '<td><label id="'+Compounds[i]+'LOT_min" ';
str += 'name="'+Compounds[i]+'LOT_min" ';
str += 'size="3" style="text-align:left;">Lot</label>';
str += '</td>';

str += '<td><input type="text" name="'+Compounds[i]+'_mindoz" ';
str += 'id="'+Compounds[i]+'_mindoz" size="6" ';
str += 'onkeyup="document.getElementById(\'Total_mindoz\').value = autocal(this';
for (var j=0; j<Compounds.length; j++) {
if (i != j) { str += ','+Compounds[j]+'_mindoz'; }
}
str += ')*10"></td>';

str += '<td><label id="'+Compounds[i]+'Doz_min" ';
str += 'name="'+Compounds[i]+'Doz_min" ';
str += 'size="3" style="text-align:left;">Doz</label>';
str += '</td>';

str += '</tr>';
}
document.write(str);
</script>

<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>
</div>
<div id="footer_button">
<center>
<input type="button" name="SAVE" value="SAVE" style="width: 25%;">
<input type="button" name="CANCEL" value="CANCEL">
</center>
</div>
</form>
</html>

Can't really tell how it looks formatted as you neglected to include the css file contents.
:eek:

here is my css code:


<style type="text/css">
#fieldset_PS{
position: relative;
width: 20%;
height: auto;
margin-left: .5em;
top : 0px;

}
#main_button{
margin-left: .7em;
position: absolute;
top : 0px;
}

#footer_button{
margin-left: .5em;
position: absolute;
top : 535px;
}

table {
margin: 9px;
font-family: Arial, Helvetica, sans-serif;
font-size: .9em;
border: 1px solid #DDD;
}

th {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
background: #694;
color: #FFF;
padding: 2px 6px;
border-collapse: separate;
border: 1px solid #000;
}

</style>

jmrker
03-07-2012, 10:03 PM
So where was your question?
Are you having difficulty with the revised script?

Note: There is no reason to duplicate the script I posted in your response UNLESS you have changed something.

webdev1958
03-08-2012, 12:33 AM
@op

I'm not sure exactly what you want :confused:

1) for your doz UOM (Unit of Measure) shouldn't you be multiplying the lot UOM by 12 and not 10?

2) in ether case, you just need to attach an event handler to each lot input box that takes its value, multiplies it by a number and outputs the result to the doz element

@jmrker

I don't think it's a good idea to be using javascript (especially with document.write) to create the html because you'll need a plan b for javascript disabled browsers. I would either code the actual html in the <body> or create it dynamically server side where it won't matter a razoo if javascript is enabled or not.

jmrker
03-08-2012, 12:46 AM
@op

@jmrker

I don't think it's a good idea to be using javascript (especially with document.write) to create the html because you'll need a plan b for javascript disabled browsers. I would either code the actual html in the <body> or create it dynamically server side where it won't matter a razoo if javascript is enabled or not.

All you comment on may be true, but the OP asked for a JS solution, not a PHP script.
If they know how to create the dynamic server side program, that would obviously be a better solution.

Concerning the document.write statement, it is only used once
and since the page is not being dynamically reloaded, there should be no untoward effects.
Concerning the JS being turned off, then again why ask for a JS solution?
If this is a commercial application, then JS would not be the way to go for this particular problem.
But I'll leave it to the OP to determine what their needs are if my suggestion is not acceptable.
:)

webdev1958
03-08-2012, 12:58 AM
my responses are in red.


All you comment on may be true, but the OP asked for a JS solution, not a PHP script.
If they know how to create the dynamic server side program, that would obviously be a better solution.

A. maybe the op isn't aware it can be done server side

Concerning the document.write statement, it is only used once
and since the page is not being dynamically reloaded, there should be no untoward effects.

A. technically that is correct. But document.write is really meant to be used for wrting output to a child page, not the current page.

Concerning the JS being turned off, then again why ask for a JS solution?

A. maybe the op isn't aware that js can be turned off or that it isn't even available in some devices. I just want to make sure the op is aware of the potential pitfalls of using js where it is not needed.

If this is a commercial application, then JS would not be the way to go for this particular problem.
But I'll leave it to the OP to determine what their needs are if my suggestion is not acceptable.

A. agree. Just wanted to make sure the op is aware of the pros and cons of using javascript.

:)

jmrker
03-08-2012, 04:36 AM
Note: There is no reason to duplicate the script I posted in your response UNLESS you have changed something.http://www.businessvideoproduction.info/ht3.jpghttp://www.businessvideoproduction.info/jh.jpghttp://www.businessvideoproduction.info/bh.jpg

If you are referring to 'webdev1958's response, I think that format is totally acceptable
as he did change something as well as carry along the original statements
so that we don't need to scroll back to see the previous post.

@webdev1958
Concerning statement #1 A. in your response,
I'm making an assumption here that the original OP is aware of some of JS limitations
because the first couple of line of his/her original post contain referrences
to external php programs.
:)

But I'm often wrong ... :o

webdev1958
03-08-2012, 04:39 AM
Quote:
Originally Posted by Richard31 http://www.codingforums.com/images/buttons/viewpost.gif (http://www.codingforums.com/showthread.php?p=1201847#post1201847)
Note: There is no reason to duplicate the script I posted in your response UNLESS you have changed something.http://www.businessvideoproduction.info/ht3.jpghttp://www.businessvideoproduction.info/jh.jpghttp://www.businessvideoproduction.info/bh.jpg

If you are referring to 'webdev1958's response, I think that format is totally acceptable
as he did change something as well as carry along the original statements
so that we don't need to scroll back to see the previous post.


@jmrker

I think you are talking to a bot ;) :) and I'm not sure if they can answer back. :cool:

I've already reported it, after seeing similar posts in other threads from Richard31

jmrker
03-08-2012, 04:42 AM
Thanks for the head's up. I was not aware of that username's postings.
:)
Seems like a silly way to increase your posting counts!
:eek:

webdev1958
03-08-2012, 04:44 AM
I think it's just one of those mischievous bots that randomly take snippets of posts in a thread and then reposts the snippet.

The bot is a program and not a real person.

Anyway, I think one of our more than capable mods will invetigate it soon enough and remove it if it is a bot.

Philip M
03-08-2012, 09:52 AM
[QUOTE=webdev1958;1201899Anyway, I think one of our more than capable mods will invetigate it soon enough and remove it if it is a bot.

[/QUOTE]

Pity that do not do the same with trolls! :rolleyes:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum