PERTANYAAN PERTAMA
<div id="bingkai_1">
<form name="info_barang_1" method="post">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<th colspan="2" align="center">Info Penjualan Barang</th>
</tr>
<tr>
<td>Tanggal :
<input type="text"
name="txtTanggal"
id="txtTanggal"
size="8"
maxlength="10"
value="<?=date('Y-m-d');?>"
onblur="LoadJual_1(); return false;"/>
</td>
<td>Total Penjualan Rp. :
<input type="text"
name="txtJual_1"
id="txtJual_1"
value="0"
size="15"
style="text-align:right"
readonly="readonly" />
</td>
</tr>
</table>
</form>
</div>
var recReq = getXmlHttpRequestObject();
var showdata_jual_1='txtJual_1'
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('Status: Cound not create XmlHttpRequest Object. Consider upgrading your browser.');
}
}
function LoadJual_1() {
document.getElementById( showdata_jual_1 ).value = 'Loading ...';
if (recReq.readyState == 4 || recReq.readyState == 0) {
recReq.open("GET", '/barang/report/info_jual_1.php', true );
recReq.onreadystatechange = function() {
if (recReq.readyState == 4 && recReq.status == 200 ) {
document.getElementById( showdata_jual_1 ).value = recReq.responseText;
}
}
recReq.send(null);
}
}
<?php
require_once( '.././opendb.php' );
$tgl = $_POST['txtTanggal'];
$sql = mysql_query( "SELECT SUM( tot_gab ) as tot_jual FROM trs WHERE tgl='$tgl'" );
while( $data = mysql_fetch_array( $sql ) ) {
echo $data['tot_jual'];
}
?>
Permasalahannya pada file PHP, jika variable
$tgl saya ganti menjadi :
$tgl = "2012-09-05" pada saat dijalankan gak ada masalah,
namun jika saya ganti Variable
$tgl menjadi :
$tgl = $_POST; jika dikalankan, Nilai Totalnya
nggak tampil ...
PERTANYAAN KEDUA
<?php if( $_POST['btn_show'] == Show ) { ?>
<div id="info_jual"></div>
<? } else { ?>
<div id="bingkai_1">
<form name="info_barang_2" method="post">
<table cellpadding="1" cellspacing="1" width="100%">
<tr>
<th>Info Penjualan Barang</th>
</tr>
<tr>
<td align="center">
<input type="submit"
name="btn_show"
id="btn_show"
value="Show"
onclick="LoadJual_2(); return false;" />
</td>
</tr>
</table>
</form>
</div>
<? } ?>
var recReq = getXmlHttpRequestObject();
var showdata_jual_2='info_jual'
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('Status: Cound not create XmlHttpRequest Object. Consider upgrading your browser.');
}
}
function LoadJual_2() {
document.getElementById( showdata_jual_2 ).innerHTML = 'Loading ...';
if (recReq.readyState == 4 || recReq.readyState == 0) {
recReq.open("GET", '/barang/report/info_jual_2.php', true );
recReq.onreadystatechange = function() {
if (recReq.readyState == 4 && recReq.status == 200 ) {
document.getElementById( showdata_jual_2 ).innerHTML = recReq.responseText;
}
}
recReq.send(null);
}
}
<?php
require_once( '.././opendb.php' );
$sql = mysql_query( "SELECT SUM( tot_gab ) as tot_jual FROM trs" );
while( $data = mysql_fetch_array( $sql ) ) {
echo $data['tot_jual'];
}
?>
Permasalahan pada pertanyaan Kedua :
Jika tombol Show diklick maka, tombol tersebut akan Hide,
dan akan tampil <div id="info_jual"></div> untuk menampilkan data Total
keseluruhan penjualan ..
Mohon pencerahannya mas,
dan maap jika saya borong semua pertanyaan ...