Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

bantuin javascript form dong mas/mbak

permisi mas/mbak mau tanya nih... jadi saya punya form seperti ini
php.lang=php
<?php
ob_start();

include "koneksi.php";

function nota_jual()
{
$querycount="Select max(ID_Jual) AS nota FROM jual";
$result=mysql_query($querycount) or die(mysql_error());
$row=mysql_fetch_array($result, MYSQL_ASSOC);
return $row['nota'];
}
$nota_jual=nota_jual();

function FormatTrans($num)
{
$num=$num+1;
switch (strlen($num))
{
default: $NoTrans = $num;
}
return $NoTrans;
}
$nota_jual="J".FormatTrans(nota_jual());
?>







$(document).ready(function(){
console.log("OK");
var target = $('#harga_jual');
target.keyup(function(){
console.log("Enter");
$('#format1').text(accounting.formatMoney(target.val(),"Rp. ", "2", ".", ","));
})
});

function addTableRow(jQtable){
jQtable.each(function(){
var $table = $(this);
var n = parseInt(document.getElementById('nomor').value) + 1;
var brg = document.getElementById('barang').value;
var qty = document.getElementById('qty').value;
var hrg = document.getElementById('harga_jual').value;
var thrg = parseInt(document.getElementById('harga_jual').value) * parseInt(document.getElementById('qty').value);
if (brg<=0) {
alert('Barang harus diisi');
}
else if (qty<=0) {
alert('QTY tidak boleh kosong atau minus');
}
else {
var brgs= brg.split('-');
var tds = '<tr>';
tds += ''+brgs[1]+'';
tds += ''+brgs[2]+'';
tds += ''+brgs[3]+'';
tds += ''+qty+'';
tds += ''+thrg+'';
tds += '
image';
tds += '';
if($('tbody', this).length > 0){
$('tbody', this).append(tds);
}else {
$(this).append(tds);
}
document.getElementById('nomor').value = n;
}
});
}



//function addHarga(){

// var $table = $(this);
// var hrg = document.getElementById('barang').value;
// var thrg = parseInt(document.getElementById('total_harga').innerHTML);

// var brgs= hrg.split('-');
// var tds = '';
// tds += ''+brgs[3]+'';
// tds += '';
// document.getElementById('harga_jual').innerHTML = thrg;
// }
function hitTotal() {
var no = parseInt(document.getElementById('nomor').value);
var tQty = parseInt(document.getElementById('total').innerHTML);
var TQty = parseInt(document.getElementById('Total').innerHTML);
var lastQty = parseInt(document.getElementById('qty['+no+']').value);
tQty += lastQty;
TQty += lastQty;
document.getElementById('total').innerHTML = tQty;
document.getElementById('Total').innerHTML = TQty;

}
function kaliTotal() {
var thrg = parseInt(document.getElementById('Total_hrg').innerHTML);
var THrg = parseInt(document.getElementById('total_hrg').innerHTML);
var LLastHrg = parseInt(document.getElementById('harga_jual').value) * parseInt(document.getElementById('qty').value);
thrg += LLastHrg;
THrg += LLastHrg;
document.getElementById('Total_hrg').innerHTML = thrg;
document.getElementById('total_hrg').innerHTML = THrg;

}
function minTotal(qty) {
var tQty = parseInt(document.getElementById('total').innerHTML);
tQty -= parseInt(qty);
document.getElementById('total').innerHTML = tQty;
}

function deleteAllRows() {
$('#tableJual tbody').remove();
document.getElementById('total').innerHTML = 0;
document.getElementById('Total_hrg').innerHTML = 0;
}
function change(){

pilih = document.getElementById("barang").value;
document.getElementById("harga_jual").innerHTML = pilih.options[pilih.selectedIndex].value;

}




Transaksi Penjualan

No. Bukti

:

" readonly>

Total :

0

Tanggal

: ' id="inputField">

 Rp.

0
Barang :


<?
$q = mysql_query("SELECT * FROM barang");
while($d = mysql_fetch_array($q)) {
echo "<option value='".$d[0]."-".$d[1]."-".$d[2]."-".$d[3]."'>".$d[1]." | ".$d[2]." | ".$d[3]."";}
?>


Banyak/Qty :
Harga Jual Rp




Kode Barang Harga Satuan Qty Total Aksi
Total : 0









nah pertanyaannya gmn caranya supaya pas setelah memilih barang langsung harga jualnya otomatis keluar sendiri.. Terimakasih

NB: Tabel Barang berisi (Id_barang, Kode_Barang, Harga_Jual, Stock, Kode_Jenis)
Sign In or Register to comment.