Rabu, 19 Maret 2014

Belajar Array ( hari.html )

Yanng Posting Unknown di 02.27 0 komentar
<head>
        <title>Belajar Array</title>
            <script type="text/javascript">
           
            var    nama_hari = new Array("Hari","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu","minggu");
            function hari()
            {
                var angka = document.getElementById("text_hari").value;
                document.getElementById("text_hasil").value = nama_hari[angka];
            }
         
            </script>
    </head>
   
    <body bgcolor=pink>
    Ketik Angka  = <input type=text id=text_hari> <br>
    <input type=button value=Cari onclick='hari();'> <br>
    Hasil Hari= <input type=text id=text_hasil>
    </body>
</html>

Rabu, 12 Maret 2014

Numeric

Yanng Posting Unknown di 03.17 0 komentar
<hmtl>
<head>
<title>Validasi Numerik</title> 
</head>
    
  <script> 
  function cekNumeric() 
  
     var cek = document.getElementById("numeric").value;
  
     if (!/^[0-9]+$/.test(cek)) 
     
        alert("INPUT DATA HARUS NUMERIC !!!"); 
        document.getElementById("numeric").value="";
     }
     else
     {
   alert ("INPUT DATA NUMERIC: "+cek);
}
  
  </script>      
     <input id="numeric" type="text"
     <input type="Button" onclick="cekNumeric()" value="cek"

</html>

Selasa, 11 Maret 2014

PERSAMAAN KUADRAT

Yanng Posting Unknown di 09.11 0 komentar
<html>
<head>
<title>PERSAMAAN KUADRAT</title>
</head>

<body bgcolor=pink>
<script type=text/javascript>
function det(a,b,c)
{
var d = (b*b)-(4*a*c);
return(d);
}
var a = parseFloat(prompt("Masukan Nilai A  \n : ax2 + bx + c = 0"));
var b = parseFloat(prompt("Masukan Nilai B  \n : ax2 + bx + c = 0"));
var c = parseFloat(prompt("Masukan Nilai C  \n : ax2 + bx + c = 0"));
var deter = det(a,b,c);

document.write("Nilai Determinan = " +deter+"<BR>");
document.write("<BR>");

if (deter>0)
{
var x1 = (-b - Math.sqrt(deter))/(2*a);
var x2 = (-b + Math.sqrt(deter))/(2*a);
document.write("Nilai x1 = " +x1+ "<BR>");
document.write("Nilai x2 = " +x2+ "<BR>");
document.write("<BR>");
document.write("Akar-akarnya Berbeda");

} else

if (deter==0)
{
var x1 = (-b - Math.sqrt(deter))/(2*a);
var x2 = (-b + Math.sqrt(deter))/(2*a);
document.write("Nilai x1 = " +x1+ "<BR>");
document.write("Nilai x2 = " +x2+ "<BR>");
document.write("<BR>");
document.write("Akar-akarnya Sama");
} else

if (deter<0)
{
document.write("Akar-akarnya Imaginer");
}
 

</script>
</body>
</html>
 

SI MATA SEMUT Template by Ipietoon Blogger Template | Gift Idea