Advertisement
GWibisono

js buat resep

Jul 8th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function MM_displayStatusMsg(msgStr) { //v1.0
  2.   status=msgStr;
  3.   document.MM_returnValue = true;
  4. }
  5.  
  6. function findObj(n, d) {
  7.     var p,i,x;
  8.     if(!d) d=document;
  9.    
  10.     if((p=n.indexOf("?"))>0 && parent.frames.length) {
  11.         d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  12.     }
  13.    
  14.     if(!(x=d[n]) && d.all) x=d.all[n];
  15.     for (i=0;!x && i < d.forms.length;i++) x=d.forms[i][n];
  16.    
  17.     for(i=0;!x&&d.layers&&i<d.layers.length;i++)
  18.         x=MM_findObj(n,d.layers[i].document);
  19.    
  20.     if(!x && document.getElementById) x=document.getElementById(n);
  21.     //alert(n);
  22.     return x;
  23.     //document.frm.
  24.    
  25. }
  26.  
  27. function stateChanged(){
  28. var c = document.frm.counter.value;
  29. var txt;
  30.     c=parseInt(c)+1;
  31.     document.frm.counter.value=c;
  32.     txt=""
  33.     //alert("tes");
  34.     for (i=5;i<=c;i++)
  35.     {
  36.          
  37.         nameObject = findObj('frm_'+i)
  38.          //findObj ('f'+i);
  39.         //if (nameObject)
  40.          //alert(i);
  41.           nameObject.style.display="";
  42.          
  43.     }
  44.  
  45.     //document.frm.add_button.disabled=true;
  46.     //document.frm.add_button.disabled=false;
  47.            
  48.      
  49. }
  50.  
  51. function MM_openBrWindow(theURL,winName,features) { //v2.0
  52.   window.open(theURL,winName,features);
  53. }
  54.  
  55. function openWin(src1, src2)
  56. {
  57.     url='cariObat.php?source1='+src1.name+'&source2='+src2.name+'&cari='+src1.value+'&t='+1341763073     window.open(url, '_obat', 'HEIGHT=250,resizable=yes,WIDTH=400');
  58.      
  59. }
  60.  
  61. function jumlah(){
  62.   num=0;
  63.  
  64. if(eval(document.post1.harga1.value)&& !isNaN(document.post1.harga1.value) )num=num+ (eval(document.post1.jml1.value) *eval(document.post1.harga1.value));
  65. if(eval(document.post1.harga2.value)&& !isNaN(document.post1.harga2.value) )num=num+ (eval(document.post1.jml2.value) *eval(document.post1.harga2.value));
  66. if(eval(document.post1.harga3.value)&& !isNaN(document.post1.harga3.value) )num=num+ (eval(document.post1.jml3.value) *eval(document.post1.harga3.value));
  67. if(eval(document.post1.harga4.value)&& !isNaN(document.post1.harga4.value) )num=num+ (eval(document.post1.jml4.value) *eval(document.post1.harga4.value));
  68. if(eval(document.post1.harga5.value)&& !isNaN(document.post1.harga5.value) )num=num+ (eval(document.post1.jml5.value) *eval(document.post1.harga5.value));
  69. if(eval(document.post1.harga6.value)&& !isNaN(document.post1.harga6.value) )num=num+ (eval(document.post1.jml6.value) *eval(document.post1.harga6.value));
  70. if(eval(document.post1.harga7.value)&& !isNaN(document.post1.harga7.value) )num=num+ (eval(document.post1.jml7.value) *eval(document.post1.harga7.value));
  71. if(eval(document.post1.harga8.value)&& !isNaN(document.post1.harga8.value) )num=num+ (eval(document.post1.jml8.value) *eval(document.post1.harga8.value));
  72. if(eval(document.post1.harga9.value)&& !isNaN(document.post1.harga9.value) )num=num+ (eval(document.post1.jml9.value) *eval(document.post1.harga9.value));
  73. if(eval(document.post1.harga10.value)&& !isNaN(document.post1.harga10.value) )num=num+ (eval(document.post1.jml10.value) *eval(document.post1.harga10.value));
  74. if(eval(document.post1.harga11.value)&& !isNaN(document.post1.harga11.value) )num=num+ (eval(document.post1.jml11.value) *eval(document.post1.harga11.value));
  75. if(eval(document.post1.harga12.value)&& !isNaN(document.post1.harga12.value) )num=num+ (eval(document.post1.jml12.value) *eval(document.post1.harga12.value));
  76. if(eval(document.post1.harga13.value)&& !isNaN(document.post1.harga13.value) )num=num+ (eval(document.post1.jml13.value) *eval(document.post1.harga13.value));
  77. if(eval(document.post1.harga14.value)&& !isNaN(document.post1.harga14.value) )num=num+ (eval(document.post1.jml14.value) *eval(document.post1.harga14.value));
  78. if(eval(document.post1.harga15.value)&& !isNaN(document.post1.harga15.value) )num=num+ (eval(document.post1.jml15.value) *eval(document.post1.harga15.value));
  79. if(eval(document.post1.harga16.value)&& !isNaN(document.post1.harga16.value) )num=num+ (eval(document.post1.jml16.value) *eval(document.post1.harga16.value));
  80. if(eval(document.post1.harga17.value)&& !isNaN(document.post1.harga17.value) )num=num+ (eval(document.post1.jml17.value) *eval(document.post1.harga17.value));
  81. if(eval(document.post1.harga18.value)&& !isNaN(document.post1.harga18.value) )num=num+ (eval(document.post1.jml18.value) *eval(document.post1.harga18.value));
  82. if(eval(document.post1.harga19.value)&& !isNaN(document.post1.harga19.value) )num=num+ (eval(document.post1.jml19.value) *eval(document.post1.harga19.value));
  83. if(eval(document.post1.harga20.value)&& !isNaN(document.post1.harga20.value) )num=num+ (eval(document.post1.jml20.value) *eval(document.post1.harga20.value));    
  84.   document.post1.helpbox.value = 'total : Rp.' + num;  
  85.   url='harga.php?tot='+num
  86.   window.open(url, 'harga', 'HEIGHT=250,resizable=yes,WIDTH=400');
  87.    
  88. }
  89.  
  90.       function makeRequest(url) {
  91.         http_request = false ;
  92.         var browser = navigator.appName;
  93.         if(browser == "Microsoft Internet Explorer"){
  94.           http_request = new ActiveXObject("Microsoft.XMLHTTP");
  95.         } else {
  96.           http_request = new XMLHttpRequest();
  97.         }
  98.         if (!http_request) {
  99.           alert ('Tidak bisa membuat XMLHTTP');
  100.           return false ;
  101.         }
  102.         http_request.onreadystatechange = alertContents;
  103.         http_request.open('GET', url, true);
  104.         //alert (url);
  105.         http_request.send(null);
  106.       }
  107.       function alertContents() {
  108.         if (http_request.readyState==4) {
  109.           if (http_request.status==200) {
  110.             var elemen=elem('listbox');
  111.             elemen.innerHTML=http_request.responseText;
  112.           } else {
  113.             alert('Gagal Request!');
  114.           }
  115.         }
  116.       }
  117.       function getposOffset(obj, offsettype){
  118.         var totaloffset=(offsettype=="left")? obj.offsetLeft : obj.offsetTop;
  119.         var parentEl=obj.offsetParent;
  120.         while (parentEl!=null){
  121.           totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
  122.           parentEl=parentEl.offsetParent;
  123.         }
  124.         return totaloffset;
  125.       }
  126.       function init() {
  127.         var elemen = document.createElement("div");
  128.         elemen.setAttribute("id","listbox");
  129.         document.body.appendChild(elemen);
  130.         elemen.style.zIndex=100;
  131.         elemen.style.position="absolute";
  132.         elemen.style.background="silver";
  133.         elemen.style.border="1px solid black";
  134.       }
  135.       function elem(id) {
  136.         return document.getElementById(id);
  137.       }
  138.       function cari(txt,id,idvalue) {
  139.         var elemen=elem('listbox');
  140.         elemen.style.left=getposOffset(elem(id),"left");
  141.         elemen.style.top=getposOffset(elem(id),"top")+21;
  142.         elemen.style.display="";
  143.         makeRequest("listObat.php?t=1341763073&text="+txt+"&id="+id+";"+idvalue);
  144.          
  145.       }
  146.      
  147.       function cariSigna(txt,id,idvalue) {
  148.         var elemen=elem('listbox');
  149.         elemen.style.left=getposOffset(elem(id),"left");
  150.         elemen.style.top=getposOffset(elem(id),"top")+21;
  151.         elemen.style.display="";
  152.         makeRequest("listSigna.php?text="+txt+"&id="+id+";"+idvalue);
  153.          
  154.       }
  155.      
  156.       function isi(txt,id,idvalue) {
  157.         elem(id).value=txt;
  158.         var elemen=elem('listbox');
  159.         elemen.style.display="none";
  160.       }
  161.       if (window.addEventListener)
  162.         window.addEventListener("load", init, false)
  163.       else if (window.attachEvent)
  164.         window.attachEvent("onload", init)
  165.       else if (document.getElementById)  
  166.         window.onload=init;  
  167.        
  168. function MM_openBrWindow(theURL,winName,features) { //v2.0
  169.   window.open(theURL,winName,features);
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement