Senin, 03 Juni 2013
Penggunaan Tombol Pada JavaScript
<!-Tampilan.HTML->
<html>
<head>
<title>Menampilkan Hari</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
function test()
{
hari = prompt("Masukkan Kode Hari (1-8)")
switch(hari)
{
case "1" :
document.write("SENIN")
break
case "2" :
document.write("SELASA")
break
case "3" :
document.write("RABU")
break
case "4" :
document.write("KAMIS")
break
case "5" :
document.write("JUMAT")
break
case "7" :
document.write("SABTU")
break
case "8" :
document.write("MINGGU")
break
default :
document.write("PERBAIKI CARA INPUT MU BRO")
}
}
</SCRIPT>
<body>
<input type ="button" name="button1" value="Switch" onclick=test()>
</body>
</html>
ScreenShoot :
<html>
<head>
<title>Menampilkan Hari</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
function test()
{
hari = prompt("Masukkan Kode Hari (1-8)")
switch(hari)
{
case "1" :
document.write("SENIN")
break
case "2" :
document.write("SELASA")
break
case "3" :
document.write("RABU")
break
case "4" :
document.write("KAMIS")
break
case "5" :
document.write("JUMAT")
break
case "7" :
document.write("SABTU")
break
case "8" :
document.write("MINGGU")
break
default :
document.write("PERBAIKI CARA INPUT MU BRO")
}
}
</SCRIPT>
<body>
<input type ="button" name="button1" value="Switch" onclick=test()>
</body>
</html>
ScreenShoot :
Tampilan Awal
Setelah Tombol Di Klik
Output
Penggunaan IF - ELSE IF - ELSE Pada JavaScript
<!-ifelse.HTML->
<HTML>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var theDay = prompt("Masukkan Kode Hari = ","")
if (theDay ==1)
{
document.write("Hari Ini Senin")
}
else if (theDay ==2)
{
document.write("Selasa")
}
else if (theDay ==3)
{
document.write("Rabu")
}
else if (theDay ==4)
{
document.write("Kamis")
}
else if (theDay ==5)
{
document.write("Jumat")
}
else if (theDay ==6)
{
document.write("Sabtu")
}
else
{
document.write("Minggu")
}
</SCRIPT>
</BODY>
</HTML>
ScreenShoot :
<HTML>
<HEAD>
<TITLE>CONTOH SELEKSI IF - ELSE</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var theDay = prompt("Masukkan Kode Hari = ","")
if (theDay ==1)
{
document.write("Hari Ini Senin")
}
else if (theDay ==2)
{
document.write("Selasa")
}
else if (theDay ==3)
{
document.write("Rabu")
}
else if (theDay ==4)
{
document.write("Kamis")
}
else if (theDay ==5)
{
document.write("Jumat")
}
else if (theDay ==6)
{
document.write("Sabtu")
}
else
{
document.write("Minggu")
}
</SCRIPT>
</BODY>
</HTML>
ScreenShoot :
Tampilan Awal
Setelah Menginput Kode
CONFIRM Pada JavaScript
<!-CONFRIM.HTML->
<HTML>
<HEAD>
<TITLE>CONFIRM</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var NAME = confirm ("Tekan Salah Satu Tombol")
if (NAME==true)
{
document.write("Anda Menekan Tombol OK")
}
else
{
document.write("Anda Menekan Tombol Cancel")
}
</SCRIPT>
</BODY>
</HTML>
ScreenShoot :
<HTML>
<HEAD>
<TITLE>CONFIRM</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var NAME = confirm ("Tekan Salah Satu Tombol")
if (NAME==true)
{
document.write("Anda Menekan Tombol OK")
}
else
{
document.write("Anda Menekan Tombol Cancel")
}
</SCRIPT>
</BODY>
</HTML>
ScreenShoot :
Tampilan Awal
Setelah Menekan Tombol OK
PROMPT Pada JavaScript
<!-PROMPT.HTML->
<HTML>
<HEAD>
<TITLE>PROMPT</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var NAME = prompt ("MASUKKAN NAMA ANDA = ","")
if (NAME!=null && NAME!="")
{
document.write("HALLO "+NAME+". APA KAREBA?")
}
</SCRIPT>
</BODY>
</HTML>
ScreenShoot :
Saknyu :D
<HTML>
<HEAD>
<TITLE>PROMPT</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var NAME = prompt ("MASUKKAN NAMA ANDA = ","")
if (NAME!=null && NAME!="")
{
document.write("HALLO "+NAME+". APA KAREBA?")
}
</SCRIPT>
</BODY>
</HTML>
ScreenShoot :
Saknyu :D
Langganan:
Postingan (Atom)