Advertisement
GWibisono

test 2

Jul 25th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. <html>
  2.   <head>
  3.     <meta name="generator"
  4.     content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
  5.     <title></title>
  6.     <script src='js/jquery.js'></script>
  7.   </head>
  8.   <body>
  9.     <input  id="clock">
  10.  
  11.     <table>
  12.       <tr>
  13.         <td>
  14.           <input id='harga_1' value=120 />
  15.         </td>
  16.         <td>
  17.           <input id='jml_1' value=21 />
  18.         </td>
  19.         <td>
  20.           <input id='tot_1' class="subtotal" />
  21.         </td>
  22.       </tr>
  23. <?
  24. for($i=2;$i<11;$i++)
  25. {?>  
  26.       <tr>
  27.         <td>
  28.           <input id='harga_<?=$i;?>' />
  29.         </td>
  30.         <td>
  31.           <input id='jml_<?=$i;?>' />
  32.         </td>
  33.         <td>
  34.           <input id='tot_<?=$i;?>' class="subtotal" />
  35.         </td>
  36.       </tr>
  37. <?
  38. }
  39. ?>
  40.     </table>
  41. <input id='total_all' >
  42. <script>
  43. hitung();
  44. var int=self.setInterval(function(){hitung()},1500);
  45. function hitung()
  46. {
  47. var i=1;done=1
  48.     while(i<100)
  49.     {
  50.        
  51.         harga="#harga_"+i;
  52.         jml="#jml_"+i;
  53.         tot="#tot_"+i;
  54.         //console.log(i+"="+$(harga).val());
  55.         if($(harga).val()!=undefined)
  56.         {
  57.             subtot=$(harga).val() * $(jml).val();
  58.             $(tot).val(subtot);
  59.             i++;
  60.         }else{
  61.             i=200;
  62.        
  63.         }
  64.     }
  65.     var tot=0;
  66.     $(".subtotal").each(function()
  67.     {
  68.         tot+=parseInt($(this).val());
  69.     });
  70.     $("#total_all").val(tot);
  71. }
  72.  
  73.  
  74. var int=self.setInterval(function(){clock()},1000);
  75. function clock()
  76.   {
  77.   var d=new Date();
  78.   var t=d.toLocaleTimeString();
  79.   document.getElementById("clock").value=t;
  80.   }
  81. </script>
  82.   </body>
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement