Cara Membuat Messages Box dengan Record
?html>
?head>
?title> Membuat Rekaman Objek ?/title>
?/head>
?body>
?script language="JavaScript">
?!--
var Record = new Array();
function Mahasiswa (npm, nama, matkul, nilai_angka, nilai_huruf) {
// Properti
this.npm = npm;
this.nama = nama;
this.matkul = matkul;
this.nilai_angka = nilai_angka;
this.nilai_huruf = nilai_huruf;
// Metode
this.LihatRecordMahasiswa = LihatRecordMahasiswa;
}
function LihatRecordMahasiswa() {
document.write("?td>" + this.npm + "?/td>");
document.write("?td>" + this.nama + "?/td>");
document.write("?td>" + this.matkul + "?/td>");
document.write("?td>" + this.nilai_angka + "?/td>");
document.write("?td>" + this.nilai_huruf + "?/td>");
}
//mengisi data
for (I=1; I?=5; I++)
{
npm=window.prompt("NPM");
nama=window.prompt("Nama");
matkul=window.prompt("Matkul");
nilai_angka=window.prompt("Nilai Angka");
if (nilai_angka ?= 49)
{nilai_huruf = "E";}
else
{
if (nilai_angka ?= 59)
{nilai_huruf = "D";}
else
{
if (nilai_angka ?= 69)
{nilai_huruf = "C";}
else
{
if (nilai_angka ?= 79)
{nilai_huruf = "B";}
else
{nilai_huruf = "A";}
}}}
Record[I] = new Mahasiswa (npm, nama, matkul, nilai_angka, nilai_huruf);
}
//menampilkan data
document.write("?table border = '1'>");
document.write("?th>NPM?/th> ?th>Nama?/th>");
document.write("?th>Matkul?/th> ?th>Nilai Angka?/th> ?th>Nilai Huruf?/th> ?br>");
for (I=1; I ? Record.length; I++)
{
document.write("?tr>");
Record[I].LihatRecordMahasiswa();
document.write("?/tr>");
}
document.write("?/table> ?br>");
//-->
?/script>
?/body>
?/html>
?head>
?title> Membuat Rekaman Objek ?/title>
?/head>
?body>
?script language="JavaScript">
?!--
var Record = new Array();
function Mahasiswa (npm, nama, matkul, nilai_angka, nilai_huruf) {
// Properti
this.npm = npm;
this.nama = nama;
this.matkul = matkul;
this.nilai_angka = nilai_angka;
this.nilai_huruf = nilai_huruf;
// Metode
this.LihatRecordMahasiswa = LihatRecordMahasiswa;
}
function LihatRecordMahasiswa() {
document.write("?td>" + this.npm + "?/td>");
document.write("?td>" + this.nama + "?/td>");
document.write("?td>" + this.matkul + "?/td>");
document.write("?td>" + this.nilai_angka + "?/td>");
document.write("?td>" + this.nilai_huruf + "?/td>");
}
//mengisi data
for (I=1; I?=5; I++)
{
npm=window.prompt("NPM");
nama=window.prompt("Nama");
matkul=window.prompt("Matkul");
nilai_angka=window.prompt("Nilai Angka");
if (nilai_angka ?= 49)
{nilai_huruf = "E";}
else
{
if (nilai_angka ?= 59)
{nilai_huruf = "D";}
else
{
if (nilai_angka ?= 69)
{nilai_huruf = "C";}
else
{
if (nilai_angka ?= 79)
{nilai_huruf = "B";}
else
{nilai_huruf = "A";}
}}}
Record[I] = new Mahasiswa (npm, nama, matkul, nilai_angka, nilai_huruf);
}
//menampilkan data
document.write("?table border = '1'>");
document.write("?th>NPM?/th> ?th>Nama?/th>");
document.write("?th>Matkul?/th> ?th>Nilai Angka?/th> ?th>Nilai Huruf?/th> ?br>");
for (I=1; I ? Record.length; I++)
{
document.write("?tr>");
Record[I].LihatRecordMahasiswa();
document.write("?/tr>");
}
document.write("?/table> ?br>");
//-->
?/script>
?/body>
?/html>
Tidak ada komentar:
Posting Komentar