Friday 27 July 2012

Cara Membuat Kalkulator Pada Blog

Sobat blogger yang saya cintai dan saya banggakan.. kali ini saya akan mengajarkan kepada anda, tepatnnya bukan mengajarkan cieh,,, tapi berbagi ilmu,, tapi ilmu saya masih sedikit jadi berbagi tips,, tapi kalo di pikir pikir saya juga kurang berpengalaman tuh,, jadi bagi apa ya?? bagi apa aja deh bole... hehehe



langsung saja ini cara memasang kalkulator pada blog

  • login ke BLOGGER.COM
  • kemudian pilih menu RANCANGAN 
  • terus ada lay out tampilan blog anda
  • tentukan dimana letak yang anda inginkan
  • lalu pilih TAMBAH WIDGET atau kalau bahasa inggrisnya ADD NEW WIDGET
  • pilih HTML JAVASCRIPT
  • paste kode yang ada di bawah
  • lalu tekan simpan

<style>


.atur {
       text-align:right;
    font-size:8pt;
      }




</style>




<script language=javascript>


function tom1()
        {document.kal.hasil.value=document.kal.hasil.value+1;}
function tom2()
        {document.kal.hasil.value=document.kal.hasil.value+2;}
function tom3()
        {document.kal.hasil.value=document.kal.hasil.value+3;}
function tom4()
        {document.kal.hasil.value=document.kal.hasil.value+4;}
function tom5()
        {document.kal.hasil.value=document.kal.hasil.value+5;}
function tom6()
        {document.kal.hasil.value=document.kal.hasil.value+6;}
function tom7()
        {document.kal.hasil.value=document.kal.hasil.value+7;}
function tom8()
        {document.kal.hasil.value=document.kal.hasil.value+8;}
function tom9()
        {document.kal.hasil.value=document.kal.hasil.value+9;}
function tom0()
        {document.kal.hasil.value=document.kal.hasil.value+0;}
function plus()
        {document.kal.simp.value=document.kal.hasil.value;
        document.kal.opr.value="+";
        document.kal.hasil.value="";}


function kalii()
        {document.kal.simp.value=document.kal.hasil.value;
        document.kal.opr.value="*";
        document.kal.hasil.value="";}
function bagii()
        {document.kal.simp.value=document.kal.hasil.value;
        document.kal.opr.value="/";
        document.kal.hasil.value="";}
function mini()
        {document.kal.simp.value=document.kal.hasil.value;
        document.kal.opr.value="-";
        document.kal.hasil.value="";}


function samadg()
{
              if(document.kal.opr.value=="+")
        {document.kal.hasil.value=eval(document.kal.simp.value)+eval(document.kal.hasil.value);}
  
        if(document.kal.opr.value=="-")
        {document.kal.hasil.value=eval(document.kal.simp.value)-eval(document.kal.hasil.value);}
  
        if(document.kal.opr.value=="*")
        {document.kal.hasil.value=eval(document.kal.simp.value)*eval(document.kal.hasil.value);}
        if(document.kal.opr.value=="/")
        {document.kal.hasil.value=eval(document.kal.simp.value)/eval(document.kal.hasil.value);}


}
      




</script>




<form name=kal>


<table border=1 bgcolor=black>
<tr>    <td colspan=4><center><input type=text name=hasil class=atur>  


<tr>    <td><input type=button name=satu value=1 onclick=tom1()>
    <td><input type=button name=dua value=2 onclick=tom2()>
    <td><input type=button name=tiga value=3 onclick=tom3()>
    <td><input type=button name=empat value=4 onclick=tom4()>




<tr>    <td><input type=button name=lima value=5 onclick=tom5()>
    <td><input type=button name=enam value=6 onclick=tom6()>
    <td><input type=button name=tujuh value=7 onclick=tom7()>
    <td><input type=button name=delapan value=8 onclick=tom8()>






<tr>    <td><input type=button name=sembilan value=9 onclick=tom9()>
    <td><input type=button name=nol value=0 onclick=tom0()>
    <td><input type=button name=tambah value=+ onclick=plus()>
    <td><input type=button name=adalah value="=" onclick=samadg()>




<tr>    <td><input type=button name=min value=- onclick=mini()>
    <td><input type=button name=kali value=* onclick=kalii()>
    <td><input type=button name=bagi value=/ onclick=bagii()>
    <td><input type=button name=back value="<<">
<tr>    <td><input type=hidden name=simp>
    <td><input type=hidden name=opr>


</table>
</form>


EmoticonEmoticon