SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto display maximum dozen after input maximum lot

    Hi..

    Now I used onclick to display the computed max doz, now I want it to auto compute after I input numbers in max lot. Is it possible?

    What code?

    here is my whole code:
    PHP Code:
    <html>
    <head>
    <title>Parameter Settings</title>

    <link rel="stylesheet" type="text/css" href="kanban.css" /> 

    <script type="text/javascript">
    //=========auto compute Total  Max=====//
    function autocalearn(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_max_lot = 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_lot += val; //accumulate
    }
    }                                                                                 
    oForm.Total_max_lot.value = Total_max_lot.toFixed(2); //out
     
    }
     </script> 
    <script type="text/javascript">
    //=========auto compute Total  bch=====//
    function autobch(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_bch_wt = 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_bch_wt += val; //accumulate
    }
    }                                                                                 
    oForm.Total_bch_wt.value = Total_bch_wt.toFixed(2); //out
     
    }

    </script>

    <script type="text/javascript">
    //=========auto compute Total  plug=====//
    function plug(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_plug_wt = 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_plug_wt += val; //accumulate
    }
    }                                                                                 
    oForm.Total_plug_wt.value = Total_plug_wt.toFixed(2); //out
     
    }

    </script>


    <script type="text/javascript">
    //============Auto compute Total Min Lot========//
    function autocalmin(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_min_lot = 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_lot += val; //accumulate
    }
    }                                                 
    oForm.Total_min_lot.value = Total_min_lot.toFixed(2); //out
     
    }
    </script>

    <script type="text/javascript">
    //Auto convert to Doz and auto compute total max doz=====////
    function doz(oText){  
        var P28_max_lot = document.getElementById("P28_max_lot").value;
        var P28_bch_wt = document.getElementById("P28_bch_wt").value;
        var P28_plug_wt = document.getElementById("P28_plug_wt").value;
        var P28_max_convert = (parseFloat(P28_max_lot) * ((parseFloat(P28_bch_wt))* parseFloat(1000)) / parseFloat(P28_plug_wt) / parseFloat(12));     
        if( !isNaN(P28_max_convert) ){   
        var P28_max_doz = document.getElementById("P28_max_doz").value = P28_max_convert.toFixed(2);
        }
        
        var P30_max_lot = document.getElementById("P30_max_lot").value;
        var P30_bch_wt = document.getElementById("P30_bch_wt").value;
        var P30_plug_wt = document.getElementById("P30_plug_wt").value;
        var P30_max_convert = (parseFloat(P30_max_lot) * ((parseFloat(P30_bch_wt))* parseFloat(1000)) / parseFloat(P30_plug_wt) / parseFloat(12)); 
        if( !isNaN(P30_max_convert) ){   
        var P30_max_doz = document.getElementById("P30_max_doz").value = P30_max_convert.toFixed(2);
        }
        
        var P32_max_lot = document.getElementById("P32_max_lot").value;
        var P32_bch_wt = document.getElementById("P32_bch_wt").value;
        var P32_plug_wt = document.getElementById("P32_plug_wt").value;
        var P32_max_convert = (parseFloat(P32_max_lot) * ((parseFloat(P32_bch_wt))* parseFloat(1000)) / parseFloat(P32_plug_wt) / parseFloat(12)); 
        if( !isNaN(P32_max_convert) ){
        var P32_max_doz = document.getElementById("P32_max_doz").value = P32_max_convert.toFixed(2);
        }
            
        var P33_max_lot = document.getElementById("P33_max_lot").value;
        var P33_bch_wt = document.getElementById("P33_bch_wt").value;
        var P33_plug_wt = document.getElementById("P33_plug_wt").value;
        var P33_max_convert = (parseFloat(P33_max_lot) * ((parseFloat(P33_bch_wt))* parseFloat(1000)) / parseFloat(P33_plug_wt) / parseFloat(12));  
        if( !isNaN(P33_max_convert) ){
        var P33_max_doz = document.getElementById("P33_max_doz").value = P33_max_convert.toFixed(2);
        }
        
        var P35_max_lot = document.getElementById("P35_max_lot").value;
        var P35_bch_wt = document.getElementById("P35_bch_wt").value;
        var P35_plug_wt = document.getElementById("P35_plug_wt").value;
        var P35_max_convert = (parseFloat(P35_max_lot) * ((parseFloat(P35_bch_wt))* parseFloat(1000)) / parseFloat(P35_plug_wt) / parseFloat(12)); 
        
        if( !isNaN(P35_max_convert) ){
        var P35_max_doz = document.getElementById("P35_max_doz").value = P35_max_convert.toFixed(2);
        }
        
        var P35M_max_lot = document.getElementById("P35M_max_lot").value; 
        var P35M_bch_wt = document.getElementById("P35M_bch_wt").value;
        var P35M_plug_wt = document.getElementById("P35M_plug_wt").value;
        var P35M_max_convert = (parseFloat(P35M_max_lot) * ((parseFloat(P35M_bch_wt))* parseFloat(1000)) / parseFloat(P35M_plug_wt) / parseFloat(12)); 
        if( !isNaN(P35M_max_convert) ){
        var P35M_max_doz = document.getElementById("P35M_max_doz").value = P35M_max_convert.toFixed(2);
        }
        
        var P35W_max_lot = document.getElementById("P35W_max_lot").value;  
        var P35W_bch_wt = document.getElementById("P35W_bch_wt").value;
        var P35W_plug_wt = document.getElementById("P35W_plug_wt").value;
        var P35W_max_convert = (parseFloat(P35W_max_lot) * ((parseFloat(P35W_bch_wt))* parseFloat(1000)) / parseFloat(P35W_plug_wt) / parseFloat(12));
        if( !isNaN(P35W_max_convert) ){
        var P35W_max_doz = document.getElementById("P35W_max_doz").value = P35W_max_convert.toFixed(2);
        }
        
        var P38_max_lot = document.getElementById("P38_max_lot").value;
        var P38_bch_wt = document.getElementById("P38_bch_wt").value;
        var P38_plug_wt = document.getElementById("P38_plug_wt").value;
        var P38_max_convert = (parseFloat(P38_max_lot) * ((parseFloat(P38_bch_wt))* parseFloat(1000)) / parseFloat(P38_plug_wt) / parseFloat(12));
        if( !isNaN(P38_max_convert) ){
        var P38_max_doz = document.getElementById("P38_max_doz").value = P38_max_convert.toFixed(2);
        }
        
        var P41_max_lot = document.getElementById("P41_max_lot").value;
        var P41_bch_wt = document.getElementById("P41_bch_wt").value;
        var P41_plug_wt = document.getElementById("P41_plug_wt").value;
        var P41_max_convert = (parseFloat(P41_max_lot) * ((parseFloat(P41_bch_wt))* parseFloat(1000)) / parseFloat(P41_plug_wt) / parseFloat(12));
        if( !isNaN(P41_max_convert) ){
        var P41_max_doz = document.getElementById("P41_max_doz").value = P41_max_convert.toFixed(2);
        }
        
        var P42_max_lot = document.getElementById("P42_max_lot").value;
        var P42_bch_wt = document.getElementById("P42_bch_wt").value;
        var P42_plug_wt = document.getElementById("P42_plug_wt").value;
        var P42_max_convert = (parseFloat(P42_max_lot) * ((parseFloat(P42_bch_wt))* parseFloat(1000)) / parseFloat(P42_plug_wt) / parseFloat(12));
        if( !isNaN(P42_max_convert) ){
        var P42_max_doz = document.getElementById("P42_max_doz").value = P42_max_convert.toFixed(2);
        }
        
        var P43_max_lot = document.getElementById("P43_max_lot").value;
        var P43_bch_wt = document.getElementById("P43_bch_wt").value;
        var P43_plug_wt = document.getElementById("P43_plug_wt").value;
        var P43_max_convert = (parseFloat(P43_max_lot) * ((parseFloat(P43_bch_wt))* parseFloat(1000)) / parseFloat(P43_plug_wt) / parseFloat(12));
        if( !isNaN(P43_max_convert) ){
        var P43_max_doz = document.getElementById("P43_max_doz").value = P43_max_convert.toFixed(2);        
        }
        
        var P46_max_lot = document.getElementById("P46_max_lot").value;
        var P46_bch_wt = document.getElementById("P46_bch_wt").value;
        var P46_plug_wt = document.getElementById("P46_plug_wt").value;
        var P46_max_convert = (parseFloat(P46_max_lot) * ((parseFloat(P46_bch_wt))* parseFloat(1000)) / parseFloat(P46_plug_wt) / parseFloat(12));
       
        if( !isNaN(P46_max_convert) ){
        var P46_max_doz = document.getElementById("P46_max_doz").value = P46_max_convert.toFixed(2);
        }
        
        var P47_max_lot = document.getElementById("P47_max_lot").value;
        var P47_bch_wt = document.getElementById("P47_bch_wt").value;
        var P47_plug_wt = document.getElementById("P47_plug_wt").value;
        var P47_max_convert = (parseFloat(P47_max_lot) * ((parseFloat(P47_bch_wt))* parseFloat(1000)) / parseFloat(P47_plug_wt) / parseFloat(12));
        
        if( !isNaN(P47_max_convert) ){
        var P47_max_doz = document.getElementById("P47_max_doz").value = P47_max_convert.toFixed(2);   
        }
        
    if (isNaN(oText.value)) //filter input
    {
    //alert('Numbers only!');
    oText.value = '';

    var field, val, oForm = oText.form, Total_max_doz = 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_doz += val; //accumulate
    }
    }
    oForm.Total_max_doz.value = Total_max_doz.toFixed(2); //out
     

    }
    </script>

    </head>
     <?php

    $con 
    mysql_connect('localhost''root','');

    mysql_select_db("mes"$con);

    ?>
    <body>
    <form name="loading_kanban" action="" method="post" onSubmit="return false">
    <div id="fieldset_PS">
    <table>
    <th>Compounds</th>
    <th>Batch Wt.</th>
    <th>UoM</th>
    <th>Plug Wt.</th>
    <th>UoM</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><input type="text" name="P28" id="P28" value="P28"></td>
    <td><input type="text" name="P28_bch_wt" id="P28_bch_wt" value="<?php echo $P28_bch_wt?>" onKeyUp="return autobch(this, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P28_bch_uom" id="P28_bch_uom" value="Kg"></td>
    <td><input type="text" name="P28_plug_wt" id="P28_plug_wt"  value="<?php echo $P28_plug_wt;?>" onKeyUp="return plug(this, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P28_plug_uom" id="P28_plug_uom" value="g" ></td> 
    <td><input type="text" name="P28_max_lot" id="P28_max_lot" value="<?php echo $P28_max_lot?>" onKeyUp="return autocalearn(this, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P28_max_lot_uom" id="P28_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P28_max_doz" id="P28_max_doz" value="<?php echo $P28_max_doz;?>" onClick="return doz(this, P30_max_doz, P32_max_doz, P33_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P28_max_doz_uom" id="P28_max_doz_uom" value="Doz"></td> 
    </tr>
    <tr>
    <td><input type="text" name="P30" id="P30" value="P30" ></td>
    <td><input type="text" name="P30_bch_wt" id="P30_bch_wt" value="<?php echo $P30_bch_wt;?>" onKeyUp="return autobch(this, P28_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P30_bch_uom" id="P30_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P30_plug_wt" id="P30_plug_wt" size="8" value="<?php echo $P30_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P30_plug_uom" id="P30_plug_uom" value="g"></td>
    <td><input type="text" name="P30_max_lot" id="P30_max_lot" value="<?php echo $P30_max_lot;?>" onKeyUp="return autocalearn(this, P28_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P30_max_lot_uom" id="P30_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P30_max_doz" id="P30_max_doz" value="<?php echo $P30_max_doz?>" onClick="return doz(this, P28_max_doz, P32_max_doz, P33_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P30_max_doz_uom" id="P30_max_doz_uom" value="Doz"></td>
    </tr>    

    <tr> 
    <td><input type="text" name="P32" id="P32" value="P32"></td>
    <td><input type="text" name="P32_bch_wt" id="P32_bch_wt" value="<?php echo $P32_bch_wt ;?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P32_bch_uom" id="P32_bch_uom" value="Kg"></td>
    <td><input type="text" name="P32_plug_wt" id="P32_plug_wt" value="<?php echo $P32_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P32_plug_uom" id="P32_plug_uom" value="g"></td>
    <td><input type="text" name="P32_max_lot" id="P32_max_lot" value="<?php echo $P32_max_lot ;?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P32_max_lot_uom" id="P32_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P32_max_doz" id="P32_max_doz" value="<?php echo $P32_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P33_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P32_max_doz_uom" id="P32_max_doz_uom" value="Doz"></td>
    </tr>   
    <tr>
    <td><input type="text" name="P33" id="P33" value="P33"></td>
    <td><input type="text" name="P33_bch_wt" id="P33_bch_wt" value="<?php echo $P33_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P33_bch_uom" id="P33_bch_uom" value="Kg"></td>
    <td><input type="text" name="P33_plug_wt" id="P33_plug_wt" value="<?php echo $P33_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P33_plug_uom" id="P33_plug_uom" value="g"></td>
    <td><input type="text" name="P33_max_lot" id="P33_max_lot" value="<?php echo $P33_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P33_max_lot_uom" id="P33_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P33_max_doz" id="P33_max_doz" value="<?php echo $P33_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P33_max_doz_uom" id="P33_max_doz_uom" value="Doz"></td>
    </tr> 
     
    <tr>
    <td><input type="text" name="P35" id="P35" value="P35"></td>
    <td><input type="text" name="P35_bch_wt" id="P35_bch_wt" value="<?php echo $P35_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P35_bch_uom" id="P35_bch_uom" value="Kg"></td>
    <td><input type="text" name="P35_plug_wt" id="P35_plug_wt" value="<?php echo $P35_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P35_plug_uom" id="P35_plug_uom" value="g"></td>
    <td><input type="text" name="P35_max_lot" id="P35_max_lot" value="<?php echo $P35_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P35_max_lot_uom" id="P35_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P35_max_doz" id="P35_max_doz" value="<?php echo $P35_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P35_max_doz_uom" id="P35_max_doz_uom" value="Doz" ></td>
    </tr>  

    <tr>
    <td><input type="text" name="P35M" id="P35M" value="P35M" ></td>
    <td><input type="text" name="P35M_bch_wt" id="P35M_bch_wt" value="<?php echo $P35M_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P35M_bch_uom" id="P35M_bch_uom" value="Kg"></td>
    <td><input type="text" name="P35M_plug_wt" id="P35M_plug_wt" value="<?php echo $P35M_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P35M_plug_uom" id="P35M_plug_uom" value="g"></td>
    <td><input type="text" name="P35M_max_lot" id="P35M_max_lot" value="<?php echo $P35M_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P35M_max_lot_uom" id="P35M_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P35M_max_doz" id="P35M_max_doz" value="<?php echo $P35M_max_doz?>" size="12" readonly="readonly" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P35M_max_doz_uom" id="P35M_max_doz_uom" value="Doz"></td>
    </tr>  

    <tr>
    <td><input type="text" name="P35W" id="P35W" value="P35W"></td>
    <td><input type="text" name="P35W_bch_wt" id="P35W_bch_wt" value="<?php echo $P35W_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P35W_bch_uom" id="P35W_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P35W_plug_wt" id="P35W_plug_wt" value="<?php echo $P35W_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P35W_plug_uom" id="P35W_plug_uom" value="g" ></td>
    <td><input type="text" name="P35W_max_lot" id="P35W_max_lot" value="<?php echo $P35W_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P35W_max_lot_uom" id="P35W_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P35W_max_doz" id="P35W_max_doz" value="<?php echo $P35W_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P35W_max_doz_uom" id="P35W_max_doz_uom" value="Doz"></td>
    </tr>  
    <tr>
    <td><input type="text" name="P38" id="P38" value="P38"></td>
    <td><input type="text" name="P38_bch_wt" id="P38_bch_wt" value="<?php echo $P38_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P38_bch_uom" id="P38_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P38_plug_wt" id="P38_plug_wt" value="<?php echo $P38_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P38_plug_uom" id="P38_plug_uom" value="g"></td>
    <td><input type="text" name="P38_max_lot" id="P38_max_lot"  value="<?php echo $P38_max_lot?>"  onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P38_max_lot_uom" id="P38_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P38_max_doz" id="P38_max_doz" value="<?php echo $P38_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P38_max_doz_uom" id="P38_max_doz_uom" value="Doz"></td>
    </tr>  
    <tr>
    <td><input type="text" name="P41" id="P41" value="P41"></td>
    <td><input type="text" name="P41_bch_wt" id="P41_bch_wt" value="<?php echo $P41_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P41_bch_uom" id="P41_bch_uom" value="Kg" > </td>
    <td><input type="text" name="P41_plug_wt" id="P41_plug_wt" value="<?php echo $P41_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P41_plug_uom" id="P41_plug_uom" value="g" ></td>
    <td><input type="text" name="P41_max_lot" id="P41_max_lot" value="<?php echo $P41_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P42_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P41_max_lot_uom" id="P41_max_lot_uom" value="Lot"> </td>
    <td><b><input type="text" name="P41_max_doz" id="P41_max_doz" value="<?php echo $P41_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P42_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"><b></td>
    <td><input type="text" name="P41_max_doz_uom" id="P41_max_doz_uom" value="Doz"></td>
    </tr>  

    <tr>
    <td><input type="text" name="P42" id="P42" value="P42"></td> 
    <td><input type="text" name="P42_bch_wt" id="P42_bch_wt" value="<?php echo $P42_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P43_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P42_bch_uom" id="P42_bch_uom" value="Kg" ></td>
    <td><input type="text" name="P42_plug_wt" id="P42_plug_wt" value="<?php echo $P42_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P43_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P42_plug_uom" id="P42_plug_uom" value="g"></td>
    <td><input type="text" name="P42_max_lot" id="P42_max_lot" value="<?php echo $P42_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P43_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P42_max_lot_uom" id="P42_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="P42_max_doz" id="P42_max_doz" value="<?php echo $P42_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P43_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P42_max_doz_uom" id="P42_max_doz_uom" value="Doz"></td>
    </tr>  

    <tr>
    <td><input type="text" name="P43" id="P43" value="P43" ></td>
    <td><input type="text" name="P43_bch_wt" id="P43_bch_wt" value="<?php echo $P43_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P46_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P43_bch_uom" id="P43_bch_uom" value="Kg"></td>
    <td><input type="text" name="P43_plug_wt" id="P43_plug_wt" value="<?php echo $P43_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P46_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P43_plug_uom" id="P43_plug_uom" value="g" ></td>
    <td><input type="text" name="P43_max_lot" id="P43_max_lot" value="<?php echo $P43_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P46_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P43_max_lot_uom" id="P43_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P43_max_doz" id="P43_max_doz" value="<?php echo $P43_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P46_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P43_max_doz_uom" id="P43_max_doz_uom" value="Doz"></td>
    </tr>  
                                      
    <tr>
    <td><input type="text" name="P46" id="P46" value="P46"></td>
    <td><input type="text" name="P46_bch_wt" id="P46_bch_wt" value="<?php echo $P46_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P47_bch_wt)"></td>
    <td><input type="text" name="P46_bch_uom" id="P46_bch_uom" value="Kg"></td>
    <td><input type="text" name="P46_plug_wt" id="P46_plug_wt"  value="<?php echo $P46_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt, P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P47_plug_wt)"></td>
    <td><input type="text" name="P46_plug_uom" id="P46_plug_uom" value="g" ></td>
    <td><input type="text" name="P46_max_lot" id="P46_max_lot" value="<?php echo $P46_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P47_max_lot)"></td>
    <td><input type="text" name="P46_max_lot_uom" id="P46_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P46_max_doz" id="P46_max_doz"  value="<?php echo $P46_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P47_max_doz)"></b></td>
    <td><input type="text" name="P46_max_doz_uom" id="P46_max_doz_uom" value="Doz"></td>
    </tr>  

    <tr>
    <td><input type="text" name="P47" id="P47" value="P47"></td>
    <td><input type="text" name="P47_bch_wt" id="P47_bch_wt" value="<?php echo $P47_bch_wt?>" onKeyUp="return autobch(this, P28_bch_wt, P30_bch_wt, P32_bch_wt, P33_bch_wt, P35_bch_wt, P35M_bch_wt, P35W_bch_wt, P38_bch_wt, P41_bch_wt, P42_bch_wt, P43_bch_wt, P46_bch_wt)"></td>
    <td><input type="text" name="P47_bch_uom" id="P47_bch_uom" value="Kg"></td>
    <td><input type="text" name="P47_plug_wt" id="P47_plug_wt" value="<?php echo $P47_plug_wt?>" onKeyUp="return plug(this, P28_plug_wt, P30_plug_wt, P32_plug_wt, P33_plug_wt,P35_plug_wt, P35M_plug_wt, P35W_plug_wt, P38_plug_wt, P41_plug_wt, P42_plug_wt, P43_plug_wt, P46_plug_wt)"></td>
    <td><input type="text" name="P47_plug_uom" id="P47_plug_uom" value="g"></td>
    <td><input type="text" name="P47_max_lot" id="P47_max_lot" value="<?php echo $P47_max_lot?>" onKeyUp="return autocalearn(this, P28_max_lot, P30_max_lot, P32_max_lot, P33_max_lot, P35_max_lot, P35M_max_lot, P35W_max_lot, P38_max_lot, P41_max_lot, P42_max_lot, P43_max_lot, P46_max_lot)"></td>
    <td><input type="text" name="P47_max_lot_uom" id="P47_max_lot_uom" value="Lot"></td>
    <td><b><input type="text" name="P47_max_doz" id="P47_max_doz" value="<?php echo $P47_max_doz?>" onClick="return doz(this, P28_max_doz, P30_max_doz, P32_max_doz, P33_max_doz,P35_max_doz, P35M_max_doz, P35W_max_doz, P38_max_doz, P41_max_doz, P42_max_doz, P43_max_doz, P46_max_doz)"></b></td>
    <td><input type="text" name="P47_max_doz_uom" id="P47_max_doz_uom" value="Doz"></td>
    </tr>  
    <tr>
    <td><input type="text" name="Total" id="Total" value="Total"></td>
    <td><input type="text" name="Total_bch_wt" id="Total_bch_wt" value="<?php echo $Total_bch_wt?>"></td>
    <td><input type="text" name="Total_bch_uom" id="Total_bch_uom" value="Kg"></td>
    <td><input type="text" name="Total_plug_wt" id="Total_plug_wt" value="<?php echo $Total_plug_wt?>" ></td>
    <td><input type="text" name="Total_plug_uom" id="Total_plug_uom" value="g"></td>
    <td><input type="text" name="Total_max_lot" id="Total_max_lot" value="<?php echo $Total_max_lot?>" ></td>
    <td><input type="text" name="Total_max_lot_uom" id="Total_max_lot_uom" value="Lot" ></td>
    <td><b><input type="text" name="Total_max_doz" id="Total_max_doz" value="<?php echo $Total_max_doz?>" ></b></td>
    <td><input type="text" name="Total_max_doz_uom" id="Total_max_doz_uom" value="Doz" ></td>
    </tr>  
    </table>
    </div>
    </form>
    </body>
    </html>
    I attach my sample form.

    Thank you so muhc
    Attached Images Attached Images

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    Now I used onclick to display the computed max doz, now I want it to auto compute after I input numbers in max lot. Is it possible?
    The max_lot fields use the autocalearn() function, so the end of that function could trigger another function to perform your desired auto compute.

    In regards to your code - wow! That's a boat-load of duplication in there.
    It is fairly easy to remove much of that duplication, such as all of the inline event attributes, and replace them entirely with something like this:

    Code javascript:
    function fieldHandler (func, fields) {
        return function () {
            return func.apply(this, fields);
        };
    }
    function fieldsOfType(type) {
        var form = this.form,
            fields = [];
        Array.prototype.forEach(form.elements, function (field) {
            if (field.name.search(type) > -1) {
                fields.push(field);
            }
        });
        return fields;
    }
     
    var form = document.getElementById('loading_kanban'),
        columns = [
            {suffix: 'bch_wt', event: 'onkeyup', func: autobch},
            {suffix: 'plug_wt', event: 'onkeyup', func: plug},
            {suffix: 'max_lot', event: 'onkeyup', func: autocalearn},
            {suffix: 'max_doz', event: 'onclick', func: doz}
        ];
     
    Array.prototype.forEach.call(form.elements, function (field) {
        columns.forEach(function (column) {
            var suffix = new RegExp(column.suffix);
            if (field.name.search(suffix) > -1) {
                fields = fieldsOfType.call(field, column.suffix);
                field[column.event] = (fieldHandler(column.func, fields));
            }
        });
    });
     
    form.onsubmit = function () {
        return false;
    };
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    The max_lot fields use the autocalearn() function, so the end of that function could trigger another function to perform your desired auto compute.

    In regards to your code - wow! That's a boat-load of duplication in there.
    It is fairly easy to remove much of that duplication, such as all of the inline event attributes, and replace them entirely with something like this:


    Code javascript:
    function fieldHandler (func, fields) {
        return function () {
            return func.apply(this, fields);
        };
    }
    function fieldsOfType(type) {
        var form = this.form,
            fields = [];
        Array.prototype.forEach(form.elements, function (field) {
            if (field.name.search(type) > -1) {
                fields.push(field);
            }
        });
        return fields;
    }
     
    var form = document.getElementById('loading_kanban'),
        columns = [
            {suffix: 'bch_wt', event: 'onkeyup', func: autobch},
            {suffix: 'plug_wt', event: 'onkeyup', func: plug},
            {suffix: 'max_lot', event: 'onkeyup', func: autocalearn},
            {suffix: 'max_doz', event: 'onclick', func: doz}
        ];
     
    Array.prototype.forEach.call(form.elements, function (field) {
        columns.forEach(function (column) {
            var suffix = new RegExp(column.suffix);
            if (field.name.search(suffix) > -1) {
                fields = fieldsOfType.call(field, column.suffix);
                field[column.event] = (fieldHandler(column.func, fields));
            }
        });
    });
     
    form.onsubmit = function () {
        return false;
    };
    what do you mean duplication entry? can you sight where in my code should I remove?

    Thank you

  4. #4
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    here is my javascript code:

    Code:
    <script type="text/javascript">
    function save_param(){
        var P28 = document.getElementById("P28").value; 
        var P28_bch_wt = document.getElementById("P28_bch_wt").value;
        var P28_bch_uom = document.getElementById("P28_bch_uom").value;
        var P28_plug_wt = document.getElementById("P28_plug_wt").value;
        var P28_plug_uom = document.getElementById("P28_plug_uom").value;
        var P28_max_lot = document.getElementById("P28_max_lot").value;
        var P28_max_lot_uom = document.getElementById("P28_max_lot_uom").value;
        var P28_max_doz = document.getElementById("P28_max_doz").value;
        var P28_max_doz_uom = document.getElementById("P28_max_doz_uom").value;
        var P28_min_lot = document.getElementById("P28_min_lot").value;
        var P28_min_lot_uom = document.getElementById("P28_min_lot_uom").value;
        var P28_min_doz = document.getElementById("P28_min_doz").value;
        var P28_min_doz_uom = document.getElementById("P28_min_doz_uom").value;
        
        var P30 = document.getElementById("P30").value; 
        var P30_bch_wt = document.getElementById("P30_bch_wt").value;
        var P30_bch_uom = document.getElementById("P30_bch_uom").value;
        var P30_plug_wt = document.getElementById("P30_plug_wt").value;
        var P30_plug_uom = document.getElementById("P30_plug_uom").value;
        var P30_max_lot = document.getElementById("P30_max_lot").value;
        var P30_max_lot_uom = document.getElementById("P30_max_lot_uom").value;
        var P30_max_doz = document.getElementById("P30_max_doz").value;
        var P30_max_doz_uom = document.getElementById("P30_max_doz_uom").value;
        var P30_min_lot = document.getElementById("P30_min_lot").value;
        var P30_min_lot_uom = document.getElementById("P30_min_lot_uom").value;
        var P30_min_doz = document.getElementById("P30_min_doz").value;
        var P30_min_doz_uom = document.getElementById("P30_min_doz_uom").value;
        
        var P32 = document.getElementById("P32").value; 
        var P32_bch_wt = document.getElementById("P32_bch_wt").value;
        var P32_bch_uom = document.getElementById("P32_bch_uom").value;
        var P32_plug_wt = document.getElementById("P32_plug_wt").value;
        var P32_plug_uom = document.getElementById("P32_plug_uom").value;
        var P32_max_lot = document.getElementById("P32_max_lot").value;
        var P32_max_lot_uom = document.getElementById("P32_max_lot_uom").value;
        var P32_max_doz = document.getElementById("P32_max_doz").value;
        var P32_max_doz_uom = document.getElementById("P32_max_doz_uom").value;
        var P32_min_lot = document.getElementById("P32_min_lot").value;
        var P32_min_lot_uom = document.getElementById("P32_min_lot_uom").value;
        var P32_min_doz = document.getElementById("P32_min_doz").value;
        var P32_min_doz_uom = document.getElementById("P32_min_doz_uom").value;
        
        var P33 = document.getElementById("P33").value; 
        var P33_bch_wt = document.getElementById("P33_bch_wt").value;
        var P33_bch_uom = document.getElementById("P33_bch_uom").value;
        var P33_plug_wt = document.getElementById("P33_plug_wt").value;
        var P33_plug_uom = document.getElementById("P33_plug_uom").value;
        var P33_max_lot = document.getElementById("P33_max_lot").value;
        var P33_max_lot_uom = document.getElementById("P33_max_lot_uom").value;
        var P33_max_doz = document.getElementById("P33_max_doz").value;
        var P33_max_doz_uom = document.getElementById("P33_max_doz_uom").value;
        var P33_min_lot = document.getElementById("P33_min_lot").value;
        var P33_min_lot_uom = document.getElementById("P33_min_lot_uom").value;
        var P33_min_doz = document.getElementById("P33_min_doz").value;
        var P33_min_doz_uom = document.getElementById("P33_min_doz_uom").value;
        
        var P35 = document.getElementById("P35").value; 
        var P35_bch_wt = document.getElementById("P35_bch_wt").value;
        var P35_bch_uom = document.getElementById("P35_bch_uom").value;
        var P35_plug_wt = document.getElementById("P35_plug_wt").value;
        var P35_plug_uom = document.getElementById("P35_plug_uom").value;
        var P35_max_lot = document.getElementById("P35_max_lot").value;
        var P35_max_lot_uom = document.getElementById("P35_max_lot_uom").value;
        var P35_max_doz = document.getElementById("P35_max_doz").value;
        var P35_max_doz_uom = document.getElementById("P35_max_doz_uom").value;
        var P35_min_lot = document.getElementById("P35_min_lot").value;
        var P35_min_lot_uom = document.getElementById("P35_min_lot_uom").value;
        var P35_min_doz = document.getElementById("P35_min_doz").value;
        var P35_min_doz_uom = document.getElementById("P35_min_doz_uom").value;
        
        var P35M = document.getElementById("P35M").value; 
        var P35M_bch_wt = document.getElementById("P35M_bch_wt").value;
        var P35M_bch_uom = document.getElementById("P35M_bch_uom").value;
        var P35M_plug_wt = document.getElementById("P35M_plug_wt").value;
        var P35M_plug_uom = document.getElementById("P35M_plug_uom").value;
        var P35M_max_lot = document.getElementById("P35M_max_lot").value;
        var P35M_max_lot_uom = document.getElementById("P35M_max_lot_uom").value;
        var P35M_max_doz = document.getElementById("P35M_max_doz").value;
        var P35M_max_doz_uom = document.getElementById("P35M_max_doz_uom").value;
        var P35M_min_lot = document.getElementById("P35M_min_lot").value;
        var P35M_min_lot_uom = document.getElementById("P35M_min_lot_uom").value;
        var P35M_min_doz = document.getElementById("P35M_min_doz").value;
        var P35M_min_doz_uom = document.getElementById("P35M_min_doz_uom").value;
        
        var P35W = document.getElementById("P35W").value; 
        var P35W_bch_wt = document.getElementById("P35W_bch_wt").value;
        var P35W_bch_uom = document.getElementById("P35W_bch_uom").value;
        var P35W_plug_wt = document.getElementById("P35W_plug_wt").value;
        var P35W_plug_uom = document.getElementById("P35W_plug_uom").value;
        var P35W_max_lot = document.getElementById("P35W_max_lot").value;
        var P35W_max_lot_uom = document.getElementById("P35W_max_lot_uom").value;
        var P35W_max_doz = document.getElementById("P35W_max_doz").value;
        var P35W_max_doz_uom = document.getElementById("P35W_max_doz_uom").value;
        var P35W_min_lot = document.getElementById("P35W_min_lot").value;
        var P35W_min_lot_uom = document.getElementById("P35W_min_lot_uom").value;
        var P35W_min_doz = document.getElementById("P35W_min_doz").value;
        var P35W_min_doz_uom = document.getElementById("P35W_min_doz_uom").value;
        
        var P38 = document.getElementById("P38").value; 
        var P38_bch_wt = document.getElementById("P38_bch_wt").value;
        var P38_bch_uom = document.getElementById("P38_bch_uom").value;
        var P38_plug_wt = document.getElementById("P38_plug_wt").value;
        var P38_plug_uom = document.getElementById("P38_plug_uom").value;
        var P38_max_lot = document.getElementById("P38_max_lot").value;
        var P38_max_lot_uom = document.getElementById("P38_max_lot_uom").value;
        var P38_max_doz = document.getElementById("P38_max_doz").value;
        var P38_max_doz_uom = document.getElementById("P38_max_doz_uom").value;
        var P38_min_lot = document.getElementById("P38_min_lot").value;
        var P38_min_lot_uom = document.getElementById("P38_min_lot_uom").value;
        var P38_min_doz = document.getElementById("P38_min_doz").value;
        var P38_min_doz_uom = document.getElementById("P38_min_doz_uom").value;
        
        var P41 = document.getElementById("P41").value; 
        var P41_bch_wt = document.getElementById("P41_bch_wt").value;
        var P41_bch_uom = document.getElementById("P41_bch_uom").value;
        var P41_plug_wt = document.getElementById("P41_plug_wt").value;
        var P41_plug_uom = document.getElementById("P41_plug_uom").value;
        var P41_max_lot = document.getElementById("P41_max_lot").value;
        var P41_max_lot_uom = document.getElementById("P41_max_lot_uom").value;
        var P41_max_doz = document.getElementById("P41_max_doz").value;
        var P41_max_doz_uom = document.getElementById("P41_max_doz_uom").value;
        var P41_min_lot = document.getElementById("P41_min_lot").value;
        var P41_min_lot_uom = document.getElementById("P41_min_lot_uom").value;
        var P41_min_doz = document.getElementById("P41_min_doz").value;
        var P41_min_doz_uom = document.getElementById("P41_min_doz_uom").value;
        
        var P42 = document.getElementById("P42").value; 
        var P42_bch_wt = document.getElementById("P42_bch_wt").value;
        var P42_bch_uom = document.getElementById("P42_bch_uom").value;
        var P42_plug_wt = document.getElementById("P42_plug_wt").value;
        var P42_plug_uom = document.getElementById("P42_plug_uom").value;
        var P42_max_lot = document.getElementById("P42_max_lot").value;
        var P42_max_lot_uom = document.getElementById("P42_max_lot_uom").value;
        var P42_max_doz = document.getElementById("P42_max_doz").value;
        var P42_max_doz_uom = document.getElementById("P42_max_doz_uom").value;
        var P42_min_lot = document.getElementById("P42_min_lot").value;
        var P42_min_lot_uom = document.getElementById("P42_min_lot_uom").value;
        var P42_min_doz = document.getElementById("P42_min_doz").value;
        var P42_min_doz_uom = document.getElementById("P42_min_doz_uom").value;
        
        var P43 = document.getElementById("P43").value; 
        var P43_bch_wt = document.getElementById("P43_bch_wt").value;
        var P43_bch_uom = document.getElementById("P43_bch_uom").value;
        var P43_plug_wt = document.getElementById("P43_plug_wt").value;
        var P43_plug_uom = document.getElementById("P43_plug_uom").value;
        var P43_max_lot = document.getElementById("P43_max_lot").value;
        var P43_max_lot_uom = document.getElementById("P43_max_lot_uom").value;
        var P43_max_doz = document.getElementById("P43_max_doz").value;
        var P43_max_doz_uom = document.getElementById("P43_max_doz_uom").value;
        var P43_min_lot = document.getElementById("P43_min_lot").value;
        var P43_min_lot_uom = document.getElementById("P43_min_lot_uom").value;
        var P43_min_doz = document.getElementById("P43_min_doz").value;
        var P43_min_doz_uom = document.getElementById("P43_min_doz_uom").value;
        
        var P46 = document.getElementById("P46").value; 
        var P46_bch_wt = document.getElementById("P46_bch_wt").value;
        var P46_bch_uom = document.getElementById("P46_bch_uom").value;
        var P46_plug_wt = document.getElementById("P46_plug_wt").value;
        var P46_plug_uom = document.getElementById("P46_plug_uom").value;
        var P46_max_lot = document.getElementById("P46_max_lot").value;
        var P46_max_lot_uom = document.getElementById("P46_max_lot_uom").value;
        var P46_max_doz = document.getElementById("P46_max_doz").value;
        var P46_max_doz_uom = document.getElementById("P46_max_doz_uom").value;
        var P46_min_lot = document.getElementById("P46_min_lot").value;
        var P46_min_lot_uom = document.getElementById("P46_min_lot_uom").value;
        var P46_min_doz = document.getElementById("P46_min_doz").value;
        var P46_min_doz_uom = document.getElementById("P46_min_doz_uom").value;
        
        var P47 = document.getElementById("P47").value; 
        var P47_bch_wt = document.getElementById("P47_bch_wt").value;
        var P47_bch_uom = document.getElementById("P47_bch_uom").value;
        var P47_plug_wt = document.getElementById("P47_plug_wt").value;
        var P47_plug_uom = document.getElementById("P47_plug_uom").value;
        var P47_max_lot = document.getElementById("P47_max_lot").value;
        var P47_max_lot_uom = document.getElementById("P47_max_lot_uom").value;
        var P47_max_doz = document.getElementById("P47_max_doz").value;
        var P47_max_doz_uom = document.getElementById("P47_max_doz_uom").value;
        var P47_min_lot = document.getElementById("P47_min_lot").value;
        var P47_min_lot_uom = document.getElementById("P47_min_lot_uom").value;
        var P47_min_doz = document.getElementById("P47_min_doz").value;
        var P47_min_doz_uom = document.getElementById("P47_min_doz_uom").value;
        
        var Total = document.getElementById("Total").value; 
        var Total_bch_wt = document.getElementById("Total_bch_wt").value;
        var Total_bch_uom = document.getElementById("Total_bch_uom").value;
        var Total_plug_wt = document.getElementById("Total_plug_wt").value;
        var Total_plug_uom = document.getElementById("Total_plug_uom").value;
        var Total_max_lot = document.getElementById("Total_max_lot").value;
        var Total_max_lot_uom = document.getElementById("Total_max_lot_uom").value;
        var Total_max_doz = document.getElementById("Total_max_doz").value;
        var Total_max_doz_uom = document.getElementById("Total_max_doz_uom").value;
        var Total_min_lot = document.getElementById("Total_min_lot").value;
        var Total_min_lot_uom = document.getElementById("Total_min_lot_uom").value;
        var Total_min_doz = document.getElementById("Total_min_doz").value;
        var Total_min_doz_uom = document.getElementById("Total_min_doz_uom").value;
        
        document.loading_kanban.action="ParameterSettingsSave.php?P28="+P28+"&P28_bch_wt="+P28_bch_wt+"&P28_bch_uom="+P28_bch_uom+"&P28_plug_wt="+P28_plug_wt+"&P28_plug_uom="+
        P28_plug_uom+"&P28_max_lot="+P28_max_lot+"&P28_max_lot_uom="+P28_max_lot_uom+"&P28_max_doz="+P28_max_doz+"&P28_max_doz_uom="+P28_max_doz_uom+
        "&P28_min_lot="+P28_min_lot+"&P28_min_lot_uom="+P28_min_lot_uom+"&P28_min_doz="+P28_min_doz+"&P28_min_doz_uom="+P28_min_doz_uom+
        "&P30="+P30+"&P30_bch_wt="+P30_bch_wt+"&P30_bch_uom="+P30_bch_uom+"&P30_plug_wt="+P30_plug_wt+"&P30_plug_uom="+
        P30_plug_uom+"&P30_max_lot="+P30_max_lot+"&P30_max_lot_uom="+P30_max_lot_uom+"&P30_max_doz="+P30_max_doz+"&P30_max_doz_uom="+P30_max_doz_uom+
        "&P30_min_lot="+P30_min_lot+"&P30_min_lot_uom="+P30_min_lot_uom+"&P30_min_doz="+P30_min_doz+"&P30_min_doz_uom="+P30_min_doz_uom+
        "&P32="+P32+"&P32_bch_wt="+P32_bch_wt+"&P32_bch_uom="+P32_bch_uom+"&P32_plug_wt="+P32_plug_wt+"&P32_plug_uom="+
        P32_plug_uom+"&P32_max_lot="+P32_max_lot+"&P32_max_lot_uom="+P32_max_lot_uom+"&P32_max_doz="+P32_max_doz+"&P32_max_doz_uom="+P32_max_doz_uom+
        "&P32_min_lot="+P32_min_lot+"&P32_min_lot_uom="+P32_min_lot_uom+"&P32_min_doz="+P32_min_doz+"&P32_min_doz_uom="+P32_min_doz_uom+
        "&P33="+P33+"&P33_bch_wt="+P33_bch_wt+"&P33_bch_uom="+P33_bch_uom+"&P33_plug_wt="+P33_plug_wt+"&P33_plug_uom="+
        P33_plug_uom+"&P33_max_lot="+P33_max_lot+"&P33_max_lot_uom="+P33_max_lot_uom+"&P33_max_doz="+P33_max_doz+"&P33_max_doz_uom="+P33_max_doz_uom+
        "&P33_min_lot="+P33_min_lot+"&P33_min_lot_uom="+P33_min_lot_uom+"&P33_min_doz="+P33_min_doz+"&P33_min_doz_uom="+P33_min_doz_uom+
        "&P35="+P35+"&P35_bch_wt="+P35_bch_wt+"&P35_bch_uom="+P35_bch_uom+"&P35_plug_wt="+P35_plug_wt+"&P35_plug_uom="+
        P35_plug_uom+"&P35_max_lot="+P35_max_lot+"&P35_max_lot_uom="+P35_max_lot_uom+"&P35_max_doz="+P35_max_doz+"&P35_max_doz_uom="+P35_max_doz_uom+
        "&P35_min_lot="+P35_min_lot+"&P35_min_lot_uom="+P35_min_lot_uom+"&P35_min_doz="+P35_min_doz+"&P35_min_doz_uom="+P35_min_doz_uom+
        "&P35M="+P35M+"&P35M_bch_wt="+P35M_bch_wt+"&P35M_bch_uom="+P35M_bch_uom+"&P35M_plug_wt="+P35M_plug_wt+"&P35M_plug_uom="+
        P35M_plug_uom+"&P35M_max_lot="+P35M_max_lot+"&P35M_max_lot_uom="+P35M_max_lot_uom+"&P35M_max_doz="+P35M_max_doz+"&P35M_max_doz_uom="+P35M_max_doz_uom+
        "&P35M_min_lot="+P35M_min_lot+"&P35M_min_lot_uom="+P35M_min_lot_uom+"&P35M_min_doz="+P35M_min_doz+"&P35M_min_doz_uom="+P35M_min_doz_uom+
        "&P35W="+P35W+"&P35W_bch_wt="+P35W_bch_wt+"&P35W_bch_uom="+P35W_bch_uom+"&P35W_plug_wt="+P35W_plug_wt+"&P35W_plug_uom="+
        P35W_plug_uom+"&P35W_max_lot="+P35W_max_lot+"&P35W_max_lot_uom="+P35W_max_lot_uom+"&P35W_max_doz="+P35W_max_doz+"&P35W_max_doz_uom="+P35W_max_doz_uom+
        "&P35W_min_lot="+P35W_min_lot+"&P35W_min_lot_uom="+P35W_min_lot_uom+"&P35W_min_doz="+P35W_min_doz+"&P35W_min_doz_uom="+P35W_min_doz_uom+
        "&P38="+P38+"&P38_bch_wt="+P38_bch_wt+"&P38_bch_uom="+P38_bch_uom+"&P38_plug_wt="+P38_plug_wt+"&P38_plug_uom="+
        P38_plug_uom+"&P38_max_lot="+P38_max_lot+"&P38_max_lot_uom="+P38_max_lot_uom+"&P38_max_doz="+P38_max_doz+"&P38_max_doz_uom="+P38_max_doz_uom+
        "&P38_min_lot="+P38_min_lot+"&P38_min_lot_uom="+P38_min_lot_uom+"&P38_min_doz="+P38_min_doz+"&P38_min_doz_uom="+P38_min_doz_uom+
        "&P41="+P41+"&P41_bch_wt="+P41_bch_wt+"&P41_bch_uom="+P41_bch_uom+"&P41_plug_wt="+P41_plug_wt+"&P41_plug_uom="+
        P41_plug_uom+"&P41_max_lot="+P41_max_lot+"&P41_max_lot_uom="+P41_max_lot_uom+"&P41_max_doz="+P41_max_doz+"&P41_max_doz_uom="+P41_max_doz_uom+
        "&P41_min_lot="+P41_min_lot+"&P41_min_lot_uom="+P41_min_lot_uom+"&P41_min_doz="+P41_min_doz+"&P41_min_doz_uom="+P41_min_doz_uom+
        "&P42="+P42+"&P42_bch_wt="+P42_bch_wt+"&P42_bch_uom="+P42_bch_uom+"&P42_plug_wt="+P42_plug_wt+"&P42_plug_uom="+
        P42_plug_uom+"&P42_max_lot="+P42_max_lot+"&P42_max_lot_uom="+P42_max_lot_uom+"&P42_max_doz="+P42_max_doz+"&P42_max_doz_uom="+P42_max_doz_uom+
        "&P42_min_lot="+P42_min_lot+"&P42_min_lot_uom="+P42_min_lot_uom+"&P42_min_doz="+P42_min_doz+"&P42_min_doz_uom="+P42_min_doz_uom+
        "&P43="+P43+"&P43_bch_wt="+P43_bch_wt+"&P43_bch_uom="+P43_bch_uom+"&P43_plug_wt="+P43_plug_wt+"&P43_plug_uom="+
        P43_plug_uom+"&P43_max_lot="+P43_max_lot+"&P43_max_lot_uom="+P43_max_lot_uom+"&P43_max_doz="+P43_max_doz+"&P43_max_doz_uom="+P43_max_doz_uom+
        "&P43_min_lot="+P43_min_lot+"&P43_min_lot_uom="+P43_min_lot_uom+"&P43_min_doz="+P43_min_doz+"&P43_min_doz_uom="+P43_min_doz_uom+
        "&P46="+P46+"&P46_bch_wt="+P46_bch_wt+"&P46_bch_uom="+P46_bch_uom+"&P46_plug_wt="+P46_plug_wt+"&P46_plug_uom="+
        P46_plug_uom+"&P46_max_lot="+P46_max_lot+"&P46_max_lot_uom="+P46_max_lot_uom+"&P46_max_doz="+P46_max_doz+"&P46_max_doz_uom="+P46_max_doz_uom+
        "&P46_min_lot="+P46_min_lot+"&P46_min_lot_uom="+P46_min_lot_uom+"&P46_min_doz="+P46_min_doz+"&P46_min_doz_uom="+P46_min_doz_uom+
        "&P47="+P47+"&P47_bch_wt="+P47_bch_wt+"&P47_bch_uom="+P47_bch_uom+"&P47_plug_wt="+P47_plug_wt+"&P47_plug_uom="+
        P47_plug_uom+"&P47_max_lot="+P47_max_lot+"&P47_max_lot_uom="+P47_max_lot_uom+"&P47_max_doz="+P47_max_doz+"&P47_max_doz_uom="+P47_max_doz_uom+
        "&P47_min_lot="+P47_min_lot+"&P47_min_lot_uom="+P47_min_lot_uom+"&P47_min_doz="+P47_min_doz+"&P47_min_doz_uom="+P47_min_doz_uom+
        "&Total="+Total+"&Total_bch_wt="+Total_bch_wt+"&Total_bch_uom="+Total_bch_uom+"&Total_plug_wt="+Total_plug_wt+"&Total_plug_uom="+
        Total_plug_uom+"&Total_max_lot="+Total_max_lot+"&Total_max_lot_uom="+Total_max_lot_uom+"&Total_max_doz="+Total_max_doz+"&Total_max_doz_uom="+Total_max_doz_uom+
        "&Total_min_lot="+Total_min_lot+"&Total_min_lot_uom="+Total_min_lot_uom+"&Total_min_doz="+Total_min_doz+"&Total_min_doz_uom="+Total_min_doz_uom;
        document.loading_kanban.submit();
        alert("Parameter Settings data save.");
        window.location="ParameterSettings.php";
    }
    
    </script>
    
    <script type="text/javascript">
    //=========auto compute Total  Max=====//
    function autocalearn(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_max_lot = 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_lot += val; //accumulate
    }
    }                                                                                 
    oForm.Total_max_lot.value = Total_max_lot.toFixed(2); //out
     
    }
     </script> 
    <script type="text/javascript">
    //=========auto compute Total  bch=====//
    function autobch(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_bch_wt = 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_bch_wt += val; //accumulate
    }
    }                                                                                 
    oForm.Total_bch_wt.value = Total_bch_wt.toFixed(2); //out
     
    }
    
    </script>
    
    <script type="text/javascript">
    //=========auto compute Total  plug=====//
    function plug(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_plug_wt = 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_plug_wt += val; //accumulate
    }
    }                                                                                 
    oForm.Total_plug_wt.value = Total_plug_wt.toFixed(2); //out
     
    }
    
    </script>
    
    
    <script type="text/javascript">
    //============Auto compute Total Min Lot========//
    function autocalmin(oText)
    {
    if (isNaN(oText.value)) //filter input
    {
    alert('Numbers only!');
    oText.value = '';
    }
    var field, val, oForm = oText.form, Total_min_lot = 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_lot += val; //accumulate
    }
    }                                                 
    oForm.Total_min_lot.value = Total_min_lot.toFixed(2); //out
     
    }
    </script>
    
    <script type="text/javascript">
    //Auto convert to Doz and auto compute total max doz=====////
    function doz(oText){  
        var P28_max_lot = document.getElementById("P28_max_lot").value;
        var P28_bch_wt = document.getElementById("P28_bch_wt").value;
        var P28_plug_wt = document.getElementById("P28_plug_wt").value;
        var P28_max_convert = (parseFloat(P28_max_lot) * ((parseFloat(P28_bch_wt))* parseFloat(1000)) / parseFloat(P28_plug_wt) / parseFloat(12));     
        if( !isNaN(P28_max_convert) ){   
        var P28_max_doz = document.getElementById("P28_max_doz").value = P28_max_convert.toFixed(2);
        }
        
        var P30_max_lot = document.getElementById("P30_max_lot").value;
        var P30_bch_wt = document.getElementById("P30_bch_wt").value;
        var P30_plug_wt = document.getElementById("P30_plug_wt").value;
        var P30_max_convert = (parseFloat(P30_max_lot) * ((parseFloat(P30_bch_wt))* parseFloat(1000)) / parseFloat(P30_plug_wt) / parseFloat(12)); 
        if( !isNaN(P30_max_convert) ){   
        var P30_max_doz = document.getElementById("P30_max_doz").value = P30_max_convert.toFixed(2);
        }
        
        var P32_max_lot = document.getElementById("P32_max_lot").value;
        var P32_bch_wt = document.getElementById("P32_bch_wt").value;
        var P32_plug_wt = document.getElementById("P32_plug_wt").value;
        var P32_max_convert = (parseFloat(P32_max_lot) * ((parseFloat(P32_bch_wt))* parseFloat(1000)) / parseFloat(P32_plug_wt) / parseFloat(12)); 
        if( !isNaN(P32_max_convert) ){
        var P32_max_doz = document.getElementById("P32_max_doz").value = P32_max_convert.toFixed(2);
        }
            
        var P33_max_lot = document.getElementById("P33_max_lot").value;
        var P33_bch_wt = document.getElementById("P33_bch_wt").value;
        var P33_plug_wt = document.getElementById("P33_plug_wt").value;
        var P33_max_convert = (parseFloat(P33_max_lot) * ((parseFloat(P33_bch_wt))* parseFloat(1000)) / parseFloat(P33_plug_wt) / parseFloat(12));  
        if( !isNaN(P33_max_convert) ){
        var P33_max_doz = document.getElementById("P33_max_doz").value = P33_max_convert.toFixed(2);
        }
        
        var P35_max_lot = document.getElementById("P35_max_lot").value;
        var P35_bch_wt = document.getElementById("P35_bch_wt").value;
        var P35_plug_wt = document.getElementById("P35_plug_wt").value;
        var P35_max_convert = (parseFloat(P35_max_lot) * ((parseFloat(P35_bch_wt))* parseFloat(1000)) / parseFloat(P35_plug_wt) / parseFloat(12)); 
        
        if( !isNaN(P35_max_convert) ){
        var P35_max_doz = document.getElementById("P35_max_doz").value = P35_max_convert.toFixed(2);
        }
        
        var P35M_max_lot = document.getElementById("P35M_max_lot").value; 
        var P35M_bch_wt = document.getElementById("P35M_bch_wt").value;
        var P35M_plug_wt = document.getElementById("P35M_plug_wt").value;
        var P35M_max_convert = (parseFloat(P35M_max_lot) * ((parseFloat(P35M_bch_wt))* parseFloat(1000)) / parseFloat(P35M_plug_wt) / parseFloat(12)); 
        if( !isNaN(P35M_max_convert) ){
        var P35M_max_doz = document.getElementById("P35M_max_doz").value = P35M_max_convert.toFixed(2);
        }
        
        var P35W_max_lot = document.getElementById("P35W_max_lot").value;  
        var P35W_bch_wt = document.getElementById("P35W_bch_wt").value;
        var P35W_plug_wt = document.getElementById("P35W_plug_wt").value;
        var P35W_max_convert = (parseFloat(P35W_max_lot) * ((parseFloat(P35W_bch_wt))* parseFloat(1000)) / parseFloat(P35W_plug_wt) / parseFloat(12));
        if( !isNaN(P35W_max_convert) ){
        var P35W_max_doz = document.getElementById("P35W_max_doz").value = P35W_max_convert.toFixed(2);
        }
        
        var P38_max_lot = document.getElementById("P38_max_lot").value;
        var P38_bch_wt = document.getElementById("P38_bch_wt").value;
        var P38_plug_wt = document.getElementById("P38_plug_wt").value;
        var P38_max_convert = (parseFloat(P38_max_lot) * ((parseFloat(P38_bch_wt))* parseFloat(1000)) / parseFloat(P38_plug_wt) / parseFloat(12));
        if( !isNaN(P38_max_convert) ){
        var P38_max_doz = document.getElementById("P38_max_doz").value = P38_max_convert.toFixed(2);
        }
        
        var P41_max_lot = document.getElementById("P41_max_lot").value;
        var P41_bch_wt = document.getElementById("P41_bch_wt").value;
        var P41_plug_wt = document.getElementById("P41_plug_wt").value;
        var P41_max_convert = (parseFloat(P41_max_lot) * ((parseFloat(P41_bch_wt))* parseFloat(1000)) / parseFloat(P41_plug_wt) / parseFloat(12));
        if( !isNaN(P41_max_convert) ){
        var P41_max_doz = document.getElementById("P41_max_doz").value = P41_max_convert.toFixed(2);
        }
        
        var P42_max_lot = document.getElementById("P42_max_lot").value;
        var P42_bch_wt = document.getElementById("P42_bch_wt").value;
        var P42_plug_wt = document.getElementById("P42_plug_wt").value;
        var P42_max_convert = (parseFloat(P42_max_lot) * ((parseFloat(P42_bch_wt))* parseFloat(1000)) / parseFloat(P42_plug_wt) / parseFloat(12));
        if( !isNaN(P42_max_convert) ){
        var P42_max_doz = document.getElementById("P42_max_doz").value = P42_max_convert.toFixed(2);
        }
        
        var P43_max_lot = document.getElementById("P43_max_lot").value;
        var P43_bch_wt = document.getElementById("P43_bch_wt").value;
        var P43_plug_wt = document.getElementById("P43_plug_wt").value;
        var P43_max_convert = (parseFloat(P43_max_lot) * ((parseFloat(P43_bch_wt))* parseFloat(1000)) / parseFloat(P43_plug_wt) / parseFloat(12));
        if( !isNaN(P43_max_convert) ){
        var P43_max_doz = document.getElementById("P43_max_doz").value = P43_max_convert.toFixed(2);        
        }
        
        var P46_max_lot = document.getElementById("P46_max_lot").value;
        var P46_bch_wt = document.getElementById("P46_bch_wt").value;
        var P46_plug_wt = document.getElementById("P46_plug_wt").value;
        var P46_max_convert = (parseFloat(P46_max_lot) * ((parseFloat(P46_bch_wt))* parseFloat(1000)) / parseFloat(P46_plug_wt) / parseFloat(12));
       
        if( !isNaN(P46_max_convert) ){
        var P46_max_doz = document.getElementById("P46_max_doz").value = P46_max_convert.toFixed(2);
        }
        
        var P47_max_lot = document.getElementById("P47_max_lot").value;
        var P47_bch_wt = document.getElementById("P47_bch_wt").value;
        var P47_plug_wt = document.getElementById("P47_plug_wt").value;
        var P47_max_convert = (parseFloat(P47_max_lot) * ((parseFloat(P47_bch_wt))* parseFloat(1000)) / parseFloat(P47_plug_wt) / parseFloat(12));
        
        if( !isNaN(P47_max_convert) ){
        var P47_max_doz = document.getElementById("P47_max_doz").value = P47_max_convert.toFixed(2);   
        }
        
    if (isNaN(oText.value)) //filter input
    {
    //alert('Numbers only!');
    oText.value = '';
    } 
    var field, val, oForm = oText.form, Total_max_doz = 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_doz += val; //accumulate
    }
    }
    oForm.Total_max_doz.value = Total_max_doz.toFixed(2); //out
     
    
    }
    </script>
    
    
    <script type="text/javascript">
    //=========auto convert mindoz and auto compute total min doz=====//
    function dozmin(oText){
        var P28_min_lot = document.getElementById("P28_min_lot").value;
        var P28_bch_wt = document.getElementById("P28_bch_wt").value;
        var P28_plug_wt = document.getElementById("P28_plug_wt").value;
        var P28_min_convert = (parseFloat(P28_min_lot) * ((parseFloat(P28_bch_wt))* parseFloat(1000)) / parseFloat(P28_plug_wt) / parseFloat(12));
        if( !isNaN(P28_min_convert) ){  
        var P28_min_doz = document.getElementById("P28_min_doz").value = P28_min_convert.toFixed(2);
        }
        
        var P30_min_lot = document.getElementById("P30_min_lot").value;
        var P30_bch_wt = document.getElementById("P30_bch_wt").value;
        var P30_plug_wt = document.getElementById("P30_plug_wt").value;
        var P30_min_convert = (parseFloat(P30_min_lot) * ((parseFloat(P30_bch_wt))* parseFloat(1000)) / parseFloat(P30_plug_wt) / parseFloat(12));
        
        if( !isNaN(P30_min_convert) ){  
        var P30_min_doz = document.getElementById("P30_min_doz").value = P30_min_convert.toFixed(2);
        }
        
        var P32_min_lot = document.getElementById("P32_min_lot").value;
        var P32_bch_wt = document.getElementById("P32_bch_wt").value;
        var P32_plug_wt = document.getElementById("P32_plug_wt").value;
        var P32_min_convert = (parseFloat(P32_min_lot) * ((parseFloat(P32_bch_wt))* parseFloat(1000)) / parseFloat(P32_plug_wt) / parseFloat(12));
       
        if( !isNaN(P32_min_convert) ){
        var P32_min_doz = document.getElementById("P32_min_doz").value = P32_min_convert.toFixed(2);
        }
        
        var P33_min_lot = document.getElementById("P33_min_lot").value;
        var P33_bch_wt = document.getElementById("P33_bch_wt").value;
        var P33_plug_wt = document.getElementById("P33_plug_wt").value;
        var P33_min_convert = (parseFloat(P33_min_lot) * ((parseFloat(P33_bch_wt))* parseFloat(1000)) / parseFloat(P33_plug_wt) / parseFloat(12));
        if( !isNaN(P33_min_convert) ){
        var P33_min_doz = document.getElementById("P33_min_doz").value = P33_min_convert.toFixed(2);
        }
        
        var P35_min_lot = document.getElementById("P35_min_lot").value;
        var P35_bch_wt = document.getElementById("P35_bch_wt").value;
        var P35_plug_wt = document.getElementById("P35_plug_wt").value;
        var P35_min_convert = (parseFloat(P35_min_lot) * ((parseFloat(P35_bch_wt))* parseFloat(1000)) / parseFloat(P35_plug_wt) / parseFloat(12));
        if( !isNaN(P35_min_convert) ){
        var P35_min_doz = document.getElementById("P35_min_doz").value = P35_min_convert.toFixed(2);
        }
        
        var P35M_min_lot = document.getElementById("P35M_min_lot").value;
        var P35M_bch_wt = document.getElementById("P35M_bch_wt").value;
        var P35M_plug_wt = document.getElementById("P35M_plug_wt").value;
        var P35M_min_convert = (parseFloat(P35M_min_lot) * ((parseFloat(P35M_bch_wt))* parseFloat(1000)) / parseFloat(P35M_plug_wt) / parseFloat(12));
        if( !isNaN(P35M_min_convert) ){
        var P35M_min_doz = document.getElementById("P35M_min_doz").value = P35M_min_convert.toFixed(2);
        }
        
        var P35W_min_lot = document.getElementById("P35W_min_lot").value;
        var P35W_bch_wt = document.getElementById("P35W_bch_wt").value;
        var P35W_plug_wt = document.getElementById("P35W_plug_wt").value;
        var P35W_min_convert = (parseFloat(P35W_min_lot) * ((parseFloat(P35W_bch_wt))* parseFloat(1000)) / parseFloat(P35W_plug_wt) / parseFloat(12));
        if( !isNaN(P35W_min_convert) ){
        var P35W_min_doz = document.getElementById("P35W_min_doz").value = P35W_min_convert.toFixed(2);
        }
        
        var P38_min_lot = document.getElementById("P38_min_lot").value;
        var P38_bch_wt = document.getElementById("P38_bch_wt").value;
        var P38_plug_wt = document.getElementById("P38_plug_wt").value;
        var P38_min_convert = (parseFloat(P38_min_lot) * ((parseFloat(P38_bch_wt))* parseFloat(1000)) / parseFloat(P38_plug_wt) / parseFloat(12));
        if( !isNaN(P38_min_convert) ){
        var P38_min_doz = document.getElementById("P38_min_doz").value = P38_min_convert.toFixed(2);
        }
        
        var P41_min_lot = document.getElementById("P41_min_lot").value;
        var P41_bch_wt = document.getElementById("P41_bch_wt").value;
        var P41_plug_wt = document.getElementById("P41_plug_wt").value;
        var P41_min_convert = (parseFloat(P41_min_lot) * ((parseFloat(P41_bch_wt))* parseFloat(1000)) / parseFloat(P41_plug_wt) / parseFloat(12));
        
        if( !isNaN(P41_min_convert) ){
        var P41_min_doz = document.getElementById("P41_min_doz").value = P41_min_convert.toFixed(2);
        }
        
        var P42_min_lot = document.getElementById("P42_min_lot").value;
        var P42_bch_wt = document.getElementById("P42_bch_wt").value;
        var P42_plug_wt = document.getElementById("P42_plug_wt").value;
        var P42_min_convert = (parseFloat(P42_min_lot) * ((parseFloat(P42_bch_wt))* parseFloat(1000)) / parseFloat(P42_plug_wt) / parseFloat(12));
    
        if( !isNaN(P42_min_convert) ){ 
        var P42_min_doz = document.getElementById("P42_min_doz").value = P42_min_convert.toFixed(2);
        }
        
        var P43_min_lot= document.getElementById("P43_min_lot").value;
        var P43_bch_wt = document.getElementById("P43_bch_wt").value;
        var P43_plug_wt = document.getElementById("P43_plug_wt").value;
        var P43_min_convert = (parseFloat(P43_min_lot) * ((parseFloat(P43_bch_wt))* parseFloat(1000)) / parseFloat(P43_plug_wt) / parseFloat(12));
      
        if( !isNaN(P43_min_convert) ){
        var P43_min_doz = document.getElementById("P43_min_doz").value = P43_min_convert.toFixed(2);        
        }
        
        var P46_min_lot = document.getElementById("P46_min_lot").value;
        var P46_bch_wt = document.getElementById("P46_bch_wt").value;
        var P46_plug_wt = document.getElementById("P46_plug_wt").value;
        var P46_min_convert = (parseFloat(P46_min_lot) * ((parseFloat(P46_bch_wt))* parseFloat(1000)) / parseFloat(P46_plug_wt) / parseFloat(12));
     
        if( !isNaN(P46_min_convert) ){
        var P46_min_doz = document.getElementById("P46_min_doz").value = P46_min_convert.toFixed(2);
        }
        
        var P47_min_lot = document.getElementById("P47_min_lot").value;
        var P47_bch_wt = document.getElementById("P47_bch_wt").value;
        var P47_plug_wt = document.getElementById("P47_plug_wt").value;
        var P47_min_convert = (parseFloat(P47_min_lot) * ((parseFloat(P47_bch_wt))* parseFloat(1000)) / parseFloat(P47_plug_wt) / parseFloat(12));
       
        if( !isNaN(P47_min_convert) ){
        var P47_min_doz = document.getElementById("P47_min_doz").value = P47_min_convert.toFixed(2);   
        }
        
    if (isNaN(oText.value)) //filter input
    {
    //alert('Numbers only!');
    oText.value = '';
    } 
    var field, val, oForm = oText.form, Total_min_doz = 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_doz += val; //accumulate
    }
    }
    oForm.Total_min_doz.value = Total_min_doz.toFixed(2); //out
    
    }
    </script>
    
    <script type="text/javascript">
    function fieldHandler (func, fields) {
        return function () {
            return func.apply(this, fields);
        };
    }
    function fieldsOfType(type) {
        var form = this.form,
            fields = [];
        Array.prototype.forEach(form.elements, function (field) {
            if (field.name.search(type) > -1) {
                fields.push(field);
            }
        });
        return fields;
    }
     
    var form = document.getElementById('loading_kanban'),
        columns = [
            {suffix: 'bch_wt', event: 'onkeyup', func: autobch},
            {suffix: 'plug_wt', event: 'onkeyup', func: plug},
            {suffix: 'max_lot', event: 'onkeyup', func: autocalearn},
            {suffix: 'max_doz', event: 'onclick', func: doz},
            {suffix: 'min_lot', event: 'onkeyup', func: autocalmin},
            {suffix: 'min_doz', event: 'onclick', func: dozmin}
        ];
     
    Array.prototype.forEach.call(form.elements, function (field) {
        columns.forEach(function (column) {
            var suffix = new RegExp(column.suffix);
            if (field.name.search(suffix) > -1) {
                fields = fieldsOfType.call(field, column.suffix);
                field[column.event] = (fieldHandler(column.func, fields));
            }
        });
    });
     
    form.onsubmit = function () {
        return false;
    };
    </script>

    and I got an error:

    Array.prototype.forEach is null or not an object.

    Where in my javascript code you said I need to remove because of duplication.

    Thank you

  5. #5
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi..

    what is the use of the code you suggested.

    Thank you

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    and I got an error:

    Array.prototype.forEach is null or not an object.
    Some web browsers are not as capable as others. There is compatibility code at the forEach documentation page which allows such browsers to make use of these features.

    Quote Originally Posted by newphpcoder View Post
    Where in my javascript code you said I need to remove because of duplication.
    As another example of duplication that can be easily dealt with, there is this:

    Code:
        var P28_max_lot = document.getElementById("P28_max_lot").value; 
        var P28_bch_wt = document.getElementById("P28_bch_wt").value; 
        var P28_plug_wt = document.getElementById("P28_plug_wt").value; 
        var P28_max_convert = (parseFloat(P28_max_lot) * ((parseFloat(P28_bch_wt))* parseFloat(1000)) / parseFloat(P28_plug_wt) / parseFloat(12));      
        if( !isNaN(P28_max_convert) ){    
        var P28_max_doz = document.getElementById("P28_max_doz").value = P28_max_convert.toFixed(2); 
        } 
         
        var P30_max_lot = document.getElementById("P30_max_lot").value; 
        var P30_bch_wt = document.getElementById("P30_bch_wt").value; 
        var P30_plug_wt = document.getElementById("P30_plug_wt").value; 
        var P30_max_convert = (parseFloat(P30_max_lot) * ((parseFloat(P30_bch_wt))* parseFloat(1000)) / parseFloat(P30_plug_wt) / parseFloat(12));  
        if( !isNaN(P30_max_convert) ){    
        var P30_max_doz = document.getElementById("P30_max_doz").value = P30_max_convert.toFixed(2); 
        } 
         
        var P32_max_lot = document.getElementById("P32_max_lot").value; 
        var P32_bch_wt = document.getElementById("P32_bch_wt").value; 
        var P32_plug_wt = document.getElementById("P32_plug_wt").value; 
        var P32_max_convert = (parseFloat(P32_max_lot) * ((parseFloat(P32_bch_wt))* parseFloat(1000)) / parseFloat(P32_plug_wt) / parseFloat(12));  
        if( !isNaN(P32_max_convert) ){ 
        var P32_max_doz = document.getElementById("P32_max_doz").value = P32_max_convert.toFixed(2); 
        } 
    
        ...
    Do you see how the structure of those three sections of code is exactly the same, and apart from a few the numbering of some variables, all is identical?

    That example code can be be reduced down to the following core code instead:

    Code javascript:
    function convertMaxDozen(prefix) {
        var max_lot = document.getElementById(prefix + '_max_lot').value,
            bch_wt = document.getElementById(prefix + '_bch_wt').value,
            plug_wt = document.getElementById(prefix + '_plug_wt').value,
            max_convert = (parseFloat(max_lot) * ((parseFloat(bch_wt)) * parseFloat(1000)) / parseFloat(plug_wt) / 12);
        if (!isNaN(max_convert)) {
            document.getElementById(prefix + '_max_doz').value = max_convert.toFixed(2);
        }
    }
     
    var prefixes = ['P28', 'P30', 'P32'];
    prefixes.forEach(convertMaxDozen);

    which now means too that the other ten sections of near-identical code can also be replaced, just be adding the prefix for them to that array.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    what is the use of the code you suggested
    To allow all of the inline HTML event attributes to be completely removed, so that scripting can more reliably assign those events to the HTML code instead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #8
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Some web browsers are not as capable as others. There is compatibility code at the forEach documentation page which allows such browsers to make use of these features.



    As another example of duplication that can be easily dealt with, there is this:

    Code:
        var P28_max_lot = document.getElementById("P28_max_lot").value; 
        var P28_bch_wt = document.getElementById("P28_bch_wt").value; 
        var P28_plug_wt = document.getElementById("P28_plug_wt").value; 
        var P28_max_convert = (parseFloat(P28_max_lot) * ((parseFloat(P28_bch_wt))* parseFloat(1000)) / parseFloat(P28_plug_wt) / parseFloat(12));      
        if( !isNaN(P28_max_convert) ){    
        var P28_max_doz = document.getElementById("P28_max_doz").value = P28_max_convert.toFixed(2); 
        } 
         
        var P30_max_lot = document.getElementById("P30_max_lot").value; 
        var P30_bch_wt = document.getElementById("P30_bch_wt").value; 
        var P30_plug_wt = document.getElementById("P30_plug_wt").value; 
        var P30_max_convert = (parseFloat(P30_max_lot) * ((parseFloat(P30_bch_wt))* parseFloat(1000)) / parseFloat(P30_plug_wt) / parseFloat(12));  
        if( !isNaN(P30_max_convert) ){    
        var P30_max_doz = document.getElementById("P30_max_doz").value = P30_max_convert.toFixed(2); 
        } 
         
        var P32_max_lot = document.getElementById("P32_max_lot").value; 
        var P32_bch_wt = document.getElementById("P32_bch_wt").value; 
        var P32_plug_wt = document.getElementById("P32_plug_wt").value; 
        var P32_max_convert = (parseFloat(P32_max_lot) * ((parseFloat(P32_bch_wt))* parseFloat(1000)) / parseFloat(P32_plug_wt) / parseFloat(12));  
        if( !isNaN(P32_max_convert) ){ 
        var P32_max_doz = document.getElementById("P32_max_doz").value = P32_max_convert.toFixed(2); 
        } 
    
        ...
    Do you see how the structure of those three sections of code is exactly the same, and apart from a few the numbering of some variables, all is identical?

    That example code can be be reduced down to the following core code instead:

    Code javascript:
    function convertMaxDozen(prefix) {
        var max_lot = document.getElementById(prefix + '_max_lot').value,
            bch_wt = document.getElementById(prefix + '_bch_wt').value,
            plug_wt = document.getElementById(prefix + '_plug_wt').value,
            max_convert = (parseFloat(max_lot) * ((parseFloat(bch_wt)) * parseFloat(1000)) / parseFloat(plug_wt) / 12);
        if (!isNaN(max_convert)) {
            document.getElementById(prefix + '_max_doz').value = max_convert.toFixed(2);
        }
    }
     
    var prefixes = ['P28', 'P30', 'P32'];
    prefixes.forEach(convertMaxDozen);

    which now means too that the other ten sections of near-identical code can also be replaced, just be adding the prefix for them to that array.
    Ok Thank you I will try your suggested code.

    on my error in prototype what should I need to do to fix that error?

    Thank you

  9. #9
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    on my error in prototype what should I need to do to fix that error?
    Some web browsers are not as capable as others. There is compatibility code at the forEach documentation page which allows such browsers to make use of these features.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #10
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I recommented this javascript code
    Code:
    <script type="text/javascript">
    //Auto convert to Doz and auto compute total max doz=====////
    /*function doz(oText){  
        var P28_max_lot = document.getElementById("P28_max_lot").value;
        var P28_bch_wt = document.getElementById("P28_bch_wt").value;
        var P28_plug_wt = document.getElementById("P28_plug_wt").value;
        var P28_max_convert = (parseFloat(P28_max_lot) * ((parseFloat(P28_bch_wt))* parseFloat(1000)) / parseFloat(P28_plug_wt) / parseFloat(12));     
        if( !isNaN(P28_max_convert) ){   
        var P28_max_doz = document.getElementById("P28_max_doz").value = P28_max_convert.toFixed(2);
        }
        
        var P30_max_lot = document.getElementById("P30_max_lot").value;
        var P30_bch_wt = document.getElementById("P30_bch_wt").value;
        var P30_plug_wt = document.getElementById("P30_plug_wt").value;
        var P30_max_convert = (parseFloat(P30_max_lot) * ((parseFloat(P30_bch_wt))* parseFloat(1000)) / parseFloat(P30_plug_wt) / parseFloat(12)); 
        if( !isNaN(P30_max_convert) ){   
        var P30_max_doz = document.getElementById("P30_max_doz").value = P30_max_convert.toFixed(2);
        }
        
        var P32_max_lot = document.getElementById("P32_max_lot").value;
        var P32_bch_wt = document.getElementById("P32_bch_wt").value;
        var P32_plug_wt = document.getElementById("P32_plug_wt").value;
        var P32_max_convert = (parseFloat(P32_max_lot) * ((parseFloat(P32_bch_wt))* parseFloat(1000)) / parseFloat(P32_plug_wt) / parseFloat(12)); 
        if( !isNaN(P32_max_convert) ){
        var P32_max_doz = document.getElementById("P32_max_doz").value = P32_max_convert.toFixed(2);
        }
            
        var P33_max_lot = document.getElementById("P33_max_lot").value;
        var P33_bch_wt = document.getElementById("P33_bch_wt").value;
        var P33_plug_wt = document.getElementById("P33_plug_wt").value;
        var P33_max_convert = (parseFloat(P33_max_lot) * ((parseFloat(P33_bch_wt))* parseFloat(1000)) / parseFloat(P33_plug_wt) / parseFloat(12));  
        if( !isNaN(P33_max_convert) ){
        var P33_max_doz = document.getElementById("P33_max_doz").value = P33_max_convert.toFixed(2);
        }
        
        var P35_max_lot = document.getElementById("P35_max_lot").value;
        var P35_bch_wt = document.getElementById("P35_bch_wt").value;
        var P35_plug_wt = document.getElementById("P35_plug_wt").value;
        var P35_max_convert = (parseFloat(P35_max_lot) * ((parseFloat(P35_bch_wt))* parseFloat(1000)) / parseFloat(P35_plug_wt) / parseFloat(12)); 
        
        if( !isNaN(P35_max_convert) ){
        var P35_max_doz = document.getElementById("P35_max_doz").value = P35_max_convert.toFixed(2);
        }
        
        var P35M_max_lot = document.getElementById("P35M_max_lot").value; 
        var P35M_bch_wt = document.getElementById("P35M_bch_wt").value;
        var P35M_plug_wt = document.getElementById("P35M_plug_wt").value;
        var P35M_max_convert = (parseFloat(P35M_max_lot) * ((parseFloat(P35M_bch_wt))* parseFloat(1000)) / parseFloat(P35M_plug_wt) / parseFloat(12)); 
        if( !isNaN(P35M_max_convert) ){
        var P35M_max_doz = document.getElementById("P35M_max_doz").value = P35M_max_convert.toFixed(2);
        }
        
        var P35W_max_lot = document.getElementById("P35W_max_lot").value;  
        var P35W_bch_wt = document.getElementById("P35W_bch_wt").value;
        var P35W_plug_wt = document.getElementById("P35W_plug_wt").value;
        var P35W_max_convert = (parseFloat(P35W_max_lot) * ((parseFloat(P35W_bch_wt))* parseFloat(1000)) / parseFloat(P35W_plug_wt) / parseFloat(12));
        if( !isNaN(P35W_max_convert) ){
        var P35W_max_doz = document.getElementById("P35W_max_doz").value = P35W_max_convert.toFixed(2);
        }
        
        var P38_max_lot = document.getElementById("P38_max_lot").value;
        var P38_bch_wt = document.getElementById("P38_bch_wt").value;
        var P38_plug_wt = document.getElementById("P38_plug_wt").value;
        var P38_max_convert = (parseFloat(P38_max_lot) * ((parseFloat(P38_bch_wt))* parseFloat(1000)) / parseFloat(P38_plug_wt) / parseFloat(12));
        if( !isNaN(P38_max_convert) ){
        var P38_max_doz = document.getElementById("P38_max_doz").value = P38_max_convert.toFixed(2);
        }
        
        var P41_max_lot = document.getElementById("P41_max_lot").value;
        var P41_bch_wt = document.getElementById("P41_bch_wt").value;
        var P41_plug_wt = document.getElementById("P41_plug_wt").value;
        var P41_max_convert = (parseFloat(P41_max_lot) * ((parseFloat(P41_bch_wt))* parseFloat(1000)) / parseFloat(P41_plug_wt) / parseFloat(12));
        if( !isNaN(P41_max_convert) ){
        var P41_max_doz = document.getElementById("P41_max_doz").value = P41_max_convert.toFixed(2);
        }
        
        var P42_max_lot = document.getElementById("P42_max_lot").value;
        var P42_bch_wt = document.getElementById("P42_bch_wt").value;
        var P42_plug_wt = document.getElementById("P42_plug_wt").value;
        var P42_max_convert = (parseFloat(P42_max_lot) * ((parseFloat(P42_bch_wt))* parseFloat(1000)) / parseFloat(P42_plug_wt) / parseFloat(12));
        if( !isNaN(P42_max_convert) ){
        var P42_max_doz = document.getElementById("P42_max_doz").value = P42_max_convert.toFixed(2);
        }
        
        var P43_max_lot = document.getElementById("P43_max_lot").value;
        var P43_bch_wt = document.getElementById("P43_bch_wt").value;
        var P43_plug_wt = document.getElementById("P43_plug_wt").value;
        var P43_max_convert = (parseFloat(P43_max_lot) * ((parseFloat(P43_bch_wt))* parseFloat(1000)) / parseFloat(P43_plug_wt) / parseFloat(12));
        if( !isNaN(P43_max_convert) ){
        var P43_max_doz = document.getElementById("P43_max_doz").value = P43_max_convert.toFixed(2);        
        }
        
        var P46_max_lot = document.getElementById("P46_max_lot").value;
        var P46_bch_wt = document.getElementById("P46_bch_wt").value;
        var P46_plug_wt = document.getElementById("P46_plug_wt").value;
        var P46_max_convert = (parseFloat(P46_max_lot) * ((parseFloat(P46_bch_wt))* parseFloat(1000)) / parseFloat(P46_plug_wt) / parseFloat(12));
       
        if( !isNaN(P46_max_convert) ){
        var P46_max_doz = document.getElementById("P46_max_doz").value = P46_max_convert.toFixed(2);
        }
        
        var P47_max_lot = document.getElementById("P47_max_lot").value;
        var P47_bch_wt = document.getElementById("P47_bch_wt").value;
        var P47_plug_wt = document.getElementById("P47_plug_wt").value;
        var P47_max_convert = (parseFloat(P47_max_lot) * ((parseFloat(P47_bch_wt))* parseFloat(1000)) / parseFloat(P47_plug_wt) / parseFloat(12));
        
        if( !isNaN(P47_max_convert) ){
        var P47_max_doz = document.getElementById("P47_max_doz").value = P47_max_convert.toFixed(2);   
        }
        
    if (isNaN(oText.value)) //filter input
    {
    //alert('Numbers only!');
    oText.value = '';
    } 
    var field, val, oForm = oText.form, Total_max_doz = 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_doz += val; //accumulate
    }
    }
    oForm.Total_max_doz.value = Total_max_doz.toFixed(2); //out
     
    
    }*/
    </script>
    and I used this:

    Code:
    <script type="text/javascript">
    function doz(prefix) {
        var max_lot = document.getElementById(prefix + '_max_lot').value,
            bch_wt = document.getElementById(prefix + '_bch_wt').value,
            plug_wt = document.getElementById(prefix + '_plug_wt').value,
            max_convert = (parseFloat(max_lot) * ((parseFloat(bch_wt)) * parseFloat(1000)) / parseFloat(plug_wt) / 12);
        if (!isNaN(max_convert)) {
            document.getElementById(prefix + '_max_doz').value = max_convert.toFixed(2);
        }
    }
     
    var prefixes = ['P28', 'P30', 'P32'];
    prefixes.forEach(doz);
    
    if (isNaN(prefix.value)) //filter input
    {
    //alert('Numbers only!');
    prefix.value = '';
    } 
    var field, val, oForm = prefix.form, Total_max_doz = 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_doz += val; //accumulate
    }
    }
    oForm.Total_max_doz.value = Total_max_doz.toFixed(2); //out
    </script>
    but I got an error:

    Object doesn't support is object or method:

    prefixes.forEach(doz);

    Thank you

  11. #11
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    I recommented this javascript code
    I'm sorry if some basic concepts aren't being understood, but some effort on your part may be needed to try and understand them.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  12. #12
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My browser is IE8..so it's not compatible in my browser, and I can't change my broser because it is my default browser, so how can we solve this error:

    Thank you so much...it their substitute code for that?

  13. #13
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to used your code, because your code is right, but it did compatible in my browser so what should i do?

    Thank you

  14. #14
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    My browser is IE8..so it's not compatible in my browser, and I can't change my broser because it is my default browser, so how can we solve this error:
    That can be resolved in the manner as explained in post #9.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  15. #15
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    That can be resolved in the manner as explained in post #9.
    I follow the link that you given, but I'm sorry I don't understand it and i cant find where on that syntax should resolve my problem.

    Thank you for your help..I really appreciated.

  16. #16
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to revise the code:

    Code:
    //Array.prototype.forEach.call(form.elements, function (field) {  
    Array.prototype.forEach = function( field ) {  
        columns.forEach(function (column) {
            var suffix = new RegExp(column.suffix);
            if (field.name.search(suffix) > -1) {
                fields = fieldsOfType.call(field, column.suffix);
                field[column.event] = (fieldHandler(column.func, fields));
            }
        });
    });
    I got an error:

    Expected ;

    Thank you

  17. #17
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    I follow the link that you given, but I'm sorry I don't understand it and i cant find where on that syntax should resolve my problem.
    The compatibility code on that page allows Internet Explorer to use this syntax, which most other web browsers are already capable of doing:

    Code javascript:
    someArray.forEach(function (value) {
        ...
    });

    If the object being worked on is not an array, but is an array-like collection instead, such as the elements object of a form, you can use this instead:

    Code javascript:
    Array.prototype.forEach.call(someCollection, function (value) {
        ...
    });

    Without being able to use the forEach method (which can easily be added to web browsers that need it with the compatibility code), you would need to use a normal for loop instead:

    Code:
    var i,
        value;
    for (i = 0; i < someArray.length; i += 1) {
        value = someArray[i];
        ...
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #18
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, i don't understand all :

    I tried this:

    Code:
    <script type="text/javascript">
    function fieldHandler (func, fields) {
        return function () {
            return func.apply(this, fields);
        };
    }
    function fieldsOfType(type) {
        var form = this.form,
            fields = [];
        Array.prototype.forEach(form.elements, function (field) {
            if (field.name.search(type) > -1) {
                fields.push(field);
            }
        });
        return fields;
    }
     
    var form = document.getElementById('loading_kanban'),
        columns = [
            {suffix: 'bch_wt', event: 'onkeyup', func: autobch},
            {suffix: 'plug_wt', event: 'onkeyup', func: plug},
            {suffix: 'max_lot', event: 'onkeyup', func: autocalearn},
            {suffix: 'max_doz', event: 'onclick', func: doz},
            {suffix: 'min_lot', event: 'onkeyup', func: autocalmin},
            {suffix: 'min_doz', event: 'onclick', func: dozmin}
        ];
     
    //Array.prototype.forEach.call(form.elements, function (field) {
    
    //Array.prototype.forEach.call(form.elements, function (field) {  
    
    Array.forEach(function (field) {
        columns.forEach(function (column) {
            var suffix = new RegExp(column.suffix);
            if (field.name.search(suffix) > -1) {
                fields = fieldsOfType.call(field, column.suffix);
                field[column.event] = (fieldHandler(column.func, fields));
            }
        });
    });
     
    form.onsubmit = function () {
        return false;
    };  
    </script>
    I got an error:

    Object doesn't support this property or method.

    what code should I need to change?and what code should I replace.

    I'm sorry it's my first time to encounter this.

    Thank you

  19. #19
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    what code should I need to change?and what code should I replace.
    You've managed to change things so that they are guaranteed to fail on all web browsers, regardless of what they support.

    I suggest that we just go back to using a normal for loop and index, to manage the loops. Hopefully you might understand those better, when you don't also have to worry about your web browser incompatibilities.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  20. #20
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You mean this:

    Code:
    var i,
        value;
    for (i = 0; i < someArray.length; i += 1) {
        value = someArray[i];
        ...
    }
    using javascript?
    Thank you

  21. #21
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    You mean this:
    Yes.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  22. #22
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is the content of somearray()?

  23. #23
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    what is the content of somearray()?
    That is sample code demonstrating the technique involved. It is not especially customized to fit your own specific situation.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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