Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta name="generator"
- content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
- <title></title>
- <script src='js/jquery.js'></script>
- </head>
- <body>
- <input id="clock">
- <table>
- <tr>
- <td>
- <input id='harga_1' value=120 />
- </td>
- <td>
- <input id='jml_1' value=21 />
- </td>
- <td>
- <input id='tot_1' class="subtotal" />
- </td>
- </tr>
- <?
- for($i=2;$i<11;$i++)
- {?>
- <tr>
- <td>
- <input id='harga_<?=$i;?>' />
- </td>
- <td>
- <input id='jml_<?=$i;?>' />
- </td>
- <td>
- <input id='tot_<?=$i;?>' class="subtotal" />
- </td>
- </tr>
- <?
- }
- ?>
- </table>
- <input id='total_all' >
- <script>
- hitung();
- var int=self.setInterval(function(){hitung()},1500);
- function hitung()
- {
- var i=1;done=1
- while(i<100)
- {
- harga="#harga_"+i;
- jml="#jml_"+i;
- tot="#tot_"+i;
- //console.log(i+"="+$(harga).val());
- if($(harga).val()!=undefined)
- {
- subtot=$(harga).val() * $(jml).val();
- $(tot).val(subtot);
- i++;
- }else{
- i=200;
- }
- }
- var tot=0;
- $(".subtotal").each(function()
- {
- tot+=parseInt($(this).val());
- });
- $("#total_all").val(tot);
- }
- var int=self.setInterval(function(){clock()},1000);
- function clock()
- {
- var d=new Date();
- var t=d.toLocaleTimeString();
- document.getElementById("clock").value=t;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement