www.webdeveloper.com
Results 1 to 1 of 1

Thread: Auto calculate conversion and display beside textbox

  1. #1
    Join Date
    Oct 2011
    Posts
    350

    Auto calculate conversion and display beside textbox

    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:

    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>
     <?php
      error_reporting(0);
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    
    mysql_select_db("mes", $con);
    ?>
    <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="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="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="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.
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles