Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

Pembahasan Soal Transaksi Penjualan Sebelumnya

Program berikut merupakan pembahasan dari kasus transaksi yang saya berikan pada postingan sebelumnya.

Mungkin pembaca lupa dengan kasusnya bisa dilihat disini.

Nama program transaksi.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Transaksi Penjualan</title>
</head>

<script type="text/javascript">
	function CekKode(Kode){
		if (Kode=='001'){
			nama = "Televisi Sony" ;
			harga = "2400000" ;
		}else if (Kode=='002'){
			nama = "DVD Player" ;
			harga = "600000" ;
		}else if (Kode=='003'){
			nama = "CD Player" ;
			hargap = "500000" ;
		}else if (Kode=='004'){
			nama = "CD Blank" ;
			harga = "3000" ;
		}else if (Kode=='005'){
			nama = "Flashdisk Kingston" ;
			harga = "300000" ;
		}else{
		    harga = "0" ;
		}
		document.getElementById("nama").value = nama ;
		document.getElementById("harga").value = harga ;
	}
		function Totalkan(Harga, Jumlah){
		var total = Harga * Jumlah ;
		var disc = 0.15 * total ;
		var pajak = 0.1 * total ;
		document.getElementById("totalharga").value = total ;
		document.getElementById("disc").value = disc ;
		document.getElementById("pajak").value = pajak ;
		document.getElementById("totalbayar").value = total-disc+pajak;
	}
</script>
<body>
<form id="jual" name="jual" method="post" action="">
  <table width="38%" border="0" cellpadding="3" cellspacing="3">
    <tr>
      <td colspan="2">Transaksi Penjualan </td>
    </tr>
    <tr>
      <td width="30%">Kode</td>
      <td width="70%">
        <select name="kode" id="kode" onchange="CekKode(document.jual.kode.value)">
          <option>001</option>
          <option>002</option>
          <option>003</option>
          <option>004</option>
        </select>
      </td>
    </tr>
    <tr>
      <td>Nama</td>
      <td> <input name="nama" type="text" id="nama" size="40" maxlength="30" onclick="blur()" />
      </td>
    </tr>
    <tr>
      <td>Harga</td>
      <td><input name="harga" type="text" id="harga" size="12" maxlength="12" onclick="blur()"/></td>
    </tr>
    <tr>
      <td>Jumlah Jual </td>
      <td><input name="jumlah" type="text" id="jumlah" size="12" maxlength="12" onkeyup="Totalkan(parseFloat(document.jual.harga.value), parseFloat(document.jual.jumlah.value))" /></td>
    </tr>
    <tr>
      <td>Total Harga </td>
      <td><input name="totalharga" type="text" id="totalharga" size="12" maxlength="12" onclick="blur()"/></td>
    </tr>
    <tr>
      <td>Discount</td>
      <td><input name="disc" type="text" id="disc" size="12" maxlength="12" onclick="blur()"/></td>
    </tr>
    <tr>
      <td>Pajak</td>
      <td><input name="pajak" type="text" id="pajak" size="12" maxlength="12" onclick="blur()"/></td>
    </tr>
    <tr>
      <td>Total Bayar</td>
      <td><input name="totalbayar" type="text" id="totalbayar" size="12" maxlength="12" onclick="blur()"/></td>
    </tr>
    <tr>
      <td colspan="2"><label>
        <input type="submit" name="Submit" value="Submit" />
        <input type="reset" name="Submit2" value="Hapus" />
      </label></td>
    </tr>
  </table>
</form>
</body>
</html>

Hasilnya yaitu

Silahkan Mencoba !

Artikel Terbaru


Advertisements

Filed under: Javascript,

Terima kasih telah memberikan komentar anda.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives Per Tahun

%d bloggers like this: