daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest Nov 27th, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.  var thoudelim = ",";
  3.  var decdelim = ".";
  4.  var curr = "";
  5.  var d=document;
  6.  
  7.  function haltnondigit(e) {
  8.   var allowkey=Array(48,49,50,51,52,53,54,55,56,57,8,9,188,190,45,46,13,33,34,35,36,37,38,39,40,112,113,114,115,116,117,118,119,120,121,123);
  9.   if(allowkey.indexOf(e.keyCode)==-1) return false;
  10.   return true;
  11.  }
  12.  function format(s,r) {
  13.   s=Math.round(s*Math.pow(10,r))/Math.pow(10,r);
  14.   s=String(s);s=s.split(".");var l=s[0].length;var t="";var c=0;
  15.   while(l>0){t=s[0][l-1]+(c%3==0&&c!=0?thoudelim:"")+t;l--;c++;}
  16.   s[1]=s[1]==undefined?"0":s[1];
  17.   for(i=s[1].length;i<r;i++) {s[1]+="0";}
  18.   return curr+t+decdelim+s[1];
  19.  }
  20.  function input_focus(t) {
  21.   t.value=t.getAttribute('ref');t.select();
  22.  }
  23.  function input_keydown(t,e) {
  24.   return haltnondigit(e);t.value=t.getAttribute('ref');
  25.  }
  26.  
  27. function input_keyup(t,i) {
  28. t.setAttribute('ref',t.value);
  29. var temp=
  30. parseFloat(document.getElementById('qty').getAttribute('rel'))-
  31. parseFloat(document.getElementById('qtypakai".$i."').getAttribute('ref'));
  32. document.getElementById('qtypakai".$i."').setAttribute('ref',temp);
  33. document.getElementById('qty').innerHTML=format(temp,2);
  34.  
  35. calc_total();
  36.  
  37. }
  38.  
  39.  
  40.  function input_onblur(t) {
  41.   t.value=format(t.value,2);
  42.   return false;
  43.  }
  44.  function calc_total() {
  45.   var x=d.getElementsByTagName("div");
  46.   var total=0;
  47.   for(i=0;i<x.length;i++) {
  48.    if(x[i].id=="jumlah") total+=isNaN(parseFloat(x[i].getAttribute("ref")))?0:parseFloat(x[i].getAttribute("ref"));
  49.   }
  50.   d.getElementById("total").value=format(total,2);
  51.  }
  52. </script>
  53. <table width="900" border="1">
  54.     <tr>
  55.       <td width="420">MATERIAL</td>
  56.       <td width="96">QTY STOCK</td>
  57.       <td width="95">QTY PAKAI</td>
  58.       <td width="209">QTY SISA</td>
  59.     </tr>
  60.  <?php
  61.     $i=1;
  62.     while($row_brg = mysql_fetch_assoc($brg)){
  63. echo "
  64.    <tr>
  65.       <td>".$row_brg['material']."</td>
  66.         <td>".$row_brg['qty']."
  67.      </td><td><input type='text' name='qtypakai".$i."' id='qtypakai".$i."' value=0,00
  68.         rel=".$row_brg['qty']."
  69.        ref='0'
  70.        onfocus='input_focus(this);'
  71.         onkeydown='return input_keydown(this,event);'      
  72.        onkeyup='input_keyup(this,".$i.");'
  73.        onblur='return input_onblur(this);'
  74.         >
  75.          </td><td><div id='jumlah' ref=0,00>0,00</div>
  76.          </td>
  77.    </tr>";
  78.     $i++;
  79.     }
  80. ?>
  81. <tr>
  82. <td colspan="3">TOTAL </td>
  83. <td><input name="total" type="text" id="total" readonly="readonly" /></td>
  84. </tr>
  85.   </table>
  86.   <p align="center">
  87.     <input type="submit" name="submit" id="submit" onclick="return tanya()" value="POSTING"  />
  88.     <input type="reset" name="reset" id="reset" value="RESET" />
  89.     <input type="hidden"name="n"value= "<?php echo $jum ?>" />
  90.     <input type="hidden" name="MM_insert" value="form2" />
  91.   </p>
  92.   <p>&nbsp;</p>
  93. </form>
  94. <script>
  95.  calc_total();
  96. </script>
  97. <p>&nbsp;</p>
RAW Paste Data
Top