RECORD
?html>
?head>
?title>Membuat Rekaman Objek?/title>
?/head>
?script language="javascript">
?!--
var Record = new Array();
function Mahasiswa(NPM,Nama,Prodi,Jenjang)
{
//properti
this.npm = NPM;
this.nama = Nama;
this.prodi = Prodi;
this.jenjang = Jenjang;
//metode
this.LihatRecordMahasiswa = LihatRecordMahasiswa;
}
function LihatRecordMahasiswa()
{
document.write("?td>"+this.npm+"?/td>");
document.write("?td>"+this.nama+"?/td>");
document.write("?td>"+this.prodi+"?/td>");
document.write("?td>"+this.jenjang+"?/td>");
}
//mengisi data
Record[0] = new Mahasiswa("43E57006085085", "Tesa", "TI", "S1");
Record[1] = new Mahasiswa("43E57006085084", "Taufik", "TI", "S1");
Record[2] = new Mahasiswa("43E57006085083", "Wasa", "TI", "S1");
Record[3] = new Mahasiswa("43E57006085082", "Wawan", "TI", "S1");
//menampilkan data
document.write("?table border='1'>" +
"?th>NPM?/th> ?th>Nama?/th> ?th>Prodi?/th> ?th>Jenjang?/th>");
for (i=0; i?Record.length; i++)
{
document.write("?tr>");
Record[i].LihatRecordMahasiswa();
document.write("?/tr>");
}
document.write("?/table>");
//-->
?/script>
?/body>
?/html>
PROGRAM DATA PEGAWAI
?html>
?head>
?title>Manipulasi Data Pegawai?/title>
?script language = "javascript" type="text/javascript">
?!--
var DBPegawai = new Array();
function Pegawai(Fields_NIP,Fields_Nama,Fields_Gaji_Per_Jam,Fields_Jam_Kerja,Fields_Gaji_Total)
{
this.NIP = Fields_NIP;
this.Nama = Fields_Nama;
this.Gaji_Jam = Fields_Gaji_Per_Jam;
this.Jam_Kerja = Fields_Jam_Kerja;
this.Gaji_Total = Fields_Gaji_Total;
}
function inputpegawai()
{
var Nama,Gaji_Per_Jam,Jam_Kerja,Gaji;
while (NIP = window.prompt("Ketikan NIP (Nomor Induk Pegawai) \n\n Click 'cancel' untuk Berhenti !!."))
{
Nama = window.prompt("Nama Pegawai");
Gaji_Per_Jam = parseInt(window.prompt("Gaji Per Jam"));
Jam_Kerja = parseInt(window.prompt("Jumlah Jam Kerja"));
Gaji = Gaji_Per_Jam * Jam_Kerja;
DBPegawai[DBPegawai.length] = new Pegawai(NIP,Nama,Gaji_Per_Jam,Jam_Kerja,Gaji);
}
ShowPegawai();
}
function ShowPegawai()
{
document.write("?table border='1'>" +
"?tr>" +
"?th>NIP?/th> ?th>Nama?/th> ?th>Gaji Per Jam?/th> ?th>Jam Kerja?/th> ?th>Gaji Total?/th>" +
"?/tr>");
for (i=0; i?DBPegawai.length; i++)
{
document.write("?tr>" +
"?td>" +DBPegawai[i].NIP+ "?/td>" +
"?td>" +DBPegawai[i].Nama+ "?/td>" +
"?td align='right'>" +DBPegawai[i].Gaji_Jam+ "?/td>" +
"?td align='right'>" +DBPegawai[i].Jam_Kerja+ "?/td>" +
"?td align='right'>" +DBPegawai[i].Gaji_Total+ "?/td>" +
"?/tr>");
}
document.write("?/table>");
}
//-->
?/script>
?/head>
?body onload = "inputpegawai();">
?/body>
?/html>
13 Juli 2009
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar