Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var thoudelim = ",";
- var decdelim = ".";
- var curr = " ";
- var d=document;
- function haltnondigit(e) {
- 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);
- if(allowkey.indexOf(e.keyCode)==-1) return false;
- return true;
- }
- function format(s,r) {
- s=Math.round(s*Math.pow(10,r))/Math.pow(10,r);
- s=String(s);s=s.split(".");var l=s[0].length;var t="";var c=0;
- while(l>0){t=s[0][l-1]+(c%3==0&&c!=0?thoudelim:"")+t;l--;c++;}
- s[1]=s[1]==undefined?"0":s[1];
- for(i=s[1].length;i<r;i++) {s[1]+="0";}
- return curr+t+decdelim+s[1];
- }
- function input_focus(t) {
- t.value=t.getAttribute('ref');t.select();
- }
- function input_keydown(t,e) {
- return haltnondigit(e);t.value=t.getAttribute('ref');
- }
- function input_keyup(t,s) {
- t.setAttribute('ref',t.value);
- if(s=="qty") {
- var temp=parseFloat(t.parentNode.nextSibling.firstChild.getAttribute('ref'))*t.value;
- t.parentNode.nextSibling.nextSibling.firstChild.setAttribute('ref',temp);
- t.parentNode.nextSibling.nextSibling.firstChild.innerHTML=format(temp,2);
- }
- else if(s=="harga") {
- var temp=parseFloat(t.parentNode.previousSibling.firstChild.getAttribute('ref'))*t.value;
- t.parentNode.nextSibling.firstChild.setAttribute('ref',temp);
- t.parentNode.nextSibling.firstChild.innerHTML=format(temp,2);
- }
- calc_total();
- }
- function input_onblur(t) {
- t.value=format(t.value,2);
- return false;
- }
- function calc_total() {
- var x=d.getElementsByTagName("DIV");
- var total=0;
- for(i=0;i<x.length;i++) {
- if(x[i].id=="subtotal") total+=isNaN(parseFloat(x[i].getAttribute("ref")))?0:parseFloat(x[i].getAttribute("ref"));
- }
- d.getElementById("total").innerHTML=format(total,2);
- }
- function MM_openBrWindow(theURL,winName,features) { //v2.0
- window.open(theURL,winName,features);
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement