javascript ไม่สามารถดึง file มาอ่านค่าได้นะ ช่วยแนะนำให้หน่อยนะคับควรแก้ไขตรงไหน
ส่วนของ หน้า Form นะคับ
Code (PHP)
<input type="text" name="Total0" id="Total0" size="10" />
Date :
2012-05-14 13:51:10
By :
computerpsu031
http://www.w3schools.com/jsref/jsref_parsefloat.asp
Code (PHP)
function calTotal()
{
//alert('11111');
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
//alert(amount);
var aaaa = document.getElementById('Price111').value;
//alert(aaaa.value);
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
// var pv = document.getElementById('PV').value;
//alert(total);
//var total = (parseInt(amount)) * (parseInt(Price.value));
//if( amount != "")
// {
//alert('1111');
//alert(total.value);
// }
// else
// {
// alert('Insert Amount please');
// document.getElementById('Code').value = "";
// document.getElementById('Detail').value = "";
// document.getElementById('Price').value = "";
// }
}
Date :
2012-05-14 14:27:06
By :
sakuraei
คับบบขอบคุณมากคับ ได้แล้ว
Date :
2012-05-14 14:41:15
By :
computerpsu031
พี่คับ เวลากลับมา เปิดใหม่ มันก็ไ่มได้อยู่นะคับ เกิดปัญหาอะไรหรอคับ
Date :
2012-05-14 15:34:12
By :
computerpsu031
Code (JavaScript)
//alert('11111');
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
//alert(amount);
var aaaa = document.getElementById('Price111').value;
//alert(aaaa.value);
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
ข้อมูลมันจะไม่ขึ้นมาในส่วนของ filed Total นะคับ
Date :
2012-05-15 09:13:15
By :
computerpsu031
<body onload="calTotal();">
Date :
2012-05-15 09:48:40
By :
sakuraei
Code (PHP)
<input type="text" name="Code0" id="Code0" onBlur="checkOrder(this), checkOrder1(this), checkOrderPV (this), calTotal1() , calTotalPV() , checkDis(this), sumTotal(), calDis(), sumcalTotal(), calVat(),sumPV(),addRow('myTable');" size="5" />
Date :
2012-05-15 10:39:57
By :
computerpsu031
ถึงพี่ ... Unidentifer
ใส่ <body onload="calTotal();"> ตรงไหนนะคับ
Date :
2012-05-15 10:40:35
By :
computerpsu031
ช่วยหน่อยนะคับ
Date :
2012-05-21 09:03:57
By :
computerpsu031
หาแท็ก <body> ครับ
แล้วแทรก onload="calTotal();" ในนั้น
Date :
2012-05-21 20:16:46
By :
sakuraei
ผมไม่เข้าใจว่าทำไม เวลาที่เราใส่ข้อมูลนะคับ มันก็ไปดึงมาจาก ฐานข้อมูลแล้ว ในส่วนของ Code นะคับ
Code (VBScript)
Code (JavaScript)
function calTotal()
{
alert('11111');
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
// alert(amount);
var aaaa = document.getElementById('Price111').value;
// alert(aaaa.value);
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
}
หากเราเปิดcomment ตรง alert('1111') นะคับ มันจำทำการ คำนวนค่าให้นะคับ แต่หากเรา ปิด Comment มันก็จะไม่คำนวนค่าให้นะคับ
ตาม URL นี้นะคับ
www.thaicreate.com/php/forum/078373.html
ช่วยอธิบายให้หน่อยว่ามันเกิดปัญหาได้ไง
Date :
2012-05-21 21:56:18
By :
computerpsu031
Code (PHP)
<input type="text" name="Code0" id="Code0" onBlur="checkOrder(this); checkOrder1(this); checkOrderPV (this); calTotal1(); calTotalPV(); checkDis(this); sumTotal(); calDis(); sumcalTotal(); calVat(); sumPV(); addRow('myTable');" size="5" />
Code (JavaScript)
function calTotal()
{
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
var aaaa = document.getElementById('Price111').value;
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
}
Date :
2012-05-21 23:23:41
By :
sakuraei
คับพี่ผมก็ใส่อยู่แล้วนะคับ
ซึ่ง code ตัวนี้จะ ผ่านะนคับ
Code (PHP)
<input type="text" name="Code0" id="Code0" onBlur="checkOrder(this), checkOrder1(this), checkOrderPV (this), calTotal() , calTotalPV() , checkDis(this), sumTotal(), calDis(), sumcalTotal(), calVat(),sumPV(),addRow('myTable');" size="5" />
Code (JavaScript)
function calTotal()
{
// alert('11111');
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
alert(amount);
var aaaa = document.getElementById('Price111').value;
// alert(aaaa.value);
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
}
ผลจากผลลัพธ์ของ code ด้านบน ** แต่ต้องมี alert
แต่ Code นี้จะไม่ผ่านนะคับ
Code (PHP)
<input type="text" name="Code0" id="Code0" onBlur="checkOrder(this); checkOrder1(this); checkOrderPV (this); calTotal1(); calTotalPV(); checkDis(this); sumTotal(); calDis(); sumcalTotal(); calVat(); sumPV(); addRow('myTable');" size="5" />
Code (JavaScript)
function calTotal()
{
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
var aaaa = document.getElementById('Price111').value;
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
}
ผลจากการโคดโปรแกรมที่ไม่มี alert
ซึ่งที่หน้าสังเกตุมันอยู่ที่ว่าทำไมเราต้อง Alert ค่าออกมาก่อนการคำนวน แล้วมันจะผ่านได้ ผมการคำนวนจะออกมาถูก
Date :
2012-05-22 09:33:20
By :
computerpsu031
ลองเอาโค้ดเต็มๆ มาลงให้ดูหน่อยดีกว่า อาจเจอที่ผิดซักที่
และ
ช่วยคลิ๊กเมาส์ขวา view page source มาลงด้วยน่ะ
Date :
2012-05-22 10:26:39
By :
sakuraei
Code (PHP)
<?
//include("../header.html");
//include ("top_menu.php");
require_once("../function.class.php");
require_once("../html.class.php");
$today = getdate();
$date_H = date(H);
$date_i = date(i);
$date_s = date(s);
$date_H1 = $date_H - 1 ;
$gettime = $date_H1.':'.$date_i.':'.$date_s;
$d = $today["mday"];
if($d <10)
{
$d1 = '0'.$d;
}
else
{
$d1 = $d;
}
$m = $today["mon"];
if($m <10)
{
$m1 = '0'.$m;
}
else
{
$m1 = $m;
}
$y = $today["year"];
$y1 = ((int)$y)+543;
//$y5 = ((int)$y1)+5;
$today1 = $d.'/'.$m.'/'.$y;
?>
<?
if($_POST['save'] != "")
{
$dbconn = getDB_Connection();
$dateselect = $_POST['dateselect'];
$dateselect1 = getDate2Pg($dateselect);
$sql_ins = 'INSERT INTO orders (bill_no, mid, order_date, paid, order_time,products_cost ) VALUES(\''.$_POST['MemberID2'].'\', \''.$_POST['MemberIDhid'].'\', '.$dateselect1.', 1, \''.$_POST['time'].'\', \''.$_POST['sumtotal'].'\' )';
mysql_select_db('summer', $dbconn);
mysql_query("SET NAMES 'utf8'");
$res_ins = mysql_query($sql_ins, $dbconn);
$sql_max = 'SELECT MAX(order_id) AS max_order FROM orders ';
mysql_select_db('summer', $dbconn);
$query_max = mysql_query($sql_max,$dbconn);
$data_max = mysql_fetch_array($query_max);
$max = $data_max['max_order'];
$no = $_POST['NO'];
$xx = count($no);
//for ($i=0;$i<$xx;$i++)
// {
echo $sql_item = 'INSERT INTO orders_items (order_id, serialno, proname, qty, uprice, PV) VALUES(\''.$max.'\', \''.$_POST['Code0'].'\',\''.$_POST['Detail0'].'\', \''.$_POST['Amount'].'\', \''.$_POST['Price0'].'\', \''.$_POST['TotalPV0'].'\' )';
mysql_select_db('summer', $dbconn);
mysql_query("SET NAMES 'utf8'");
$res_item = mysql_query($sql_item, $dbconn);
// }
?>
<script language="javascript">//alert('Save Successfull');</script>
<?
}
?>
<!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"><!-- InstanceBegin template="/Templates/main_admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Summer of 1955</title>
<!-- InstanceEndEditable -->
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
</script>
<link href="../css/summer.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body background="../img/summer_bg.jpg" style="background-repeat:repeat-x">
<table align="center" width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50" align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top"><img src="../img/summer_indexhead.png" width="1024" height="71" /></td>
</tr>
<tr>
<td align="left" valign="top" background="../img/summer_allbg.png" style="background-repeat:repeat-y" height="2"></td>
</tr
><tr>
<td align="left" valign="top" background="../img/summer_allbg.png" style="background-repeat:repeat-y"><table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17" align="left" valign="top"> </td>
<td width="230" align="left" valign="top" bgcolor="#eff0ea"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="100" align="center" valign="top" style="padding-top:50px"><img src="../img/membermenu.jpg" width="160" height="160" /></td>
</tr>
<tr>
<td style="padding-left:30px"> </td>
</tr>
<!--<tr>
<td style="padding-left:30px"><a href="#" class="sidemenulink">• Profile</a></td>
</tr>
<tr>
<td align="left" valign="top" class="blacktext11" style="padding-left:30px">...........................................</td>
</tr>
<tr>
<td style="padding-left:30px"><a href="#" class="sidemenulink">• Statement</a></td>
</tr>
<tr>
<td class="blacktext11" style="padding-left:30px">...........................................</td>
</tr>
<tr>
<td style="padding-left:30px"><a href="#" class="sidemenulink">• Bonus</a></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>-->
<tr>
<td> </td>
</tr>
</table></td>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="760" height="48" align="left" valign="bottom" bgcolor="#eff0ea"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="50" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="member_search.php" target="_parent" class="greenlink">Member</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="80" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="payment.php" target="_parent" class="greenlink">Payment</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="loi_form.php" target="_parent" class="greenlink">LOI Form</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="loi_approve.php" target="_parent" class="greenlink">LOI Approve</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="add_bonus_rate.php" target="_parent" class="greenlink">System Setup</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="logout.php" target="_parent" class="greenlink">Logout</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<!-- <td width="19" align="left" valign="top"><img src="../img/summer_menubgleftgrey.jpg" width="19" height="35" /></td>
<td width="160" align="center" valign="middle" background="img/summer_menubgmidgrey.jpg" class="whitetext13bold" style="background-repeat:repeat-x">For Summer's Members</td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgrightgrey.jpg" width="19" height="35" /></td>-->
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top"><img src="../img/memberpic.jpg" width="758" height="270" /></td>
</tr>
<tr>
<td> <!-- InstanceBeginEditable name="EditRegion5" -->
<form name="payment" method="post" action=""><table width="90%" border="0 " class="blackbold" align="center" >
<tr>
<td colspan="6" align="center" bgcolor="#9fad53" class="whitetext13bold"><SPAN closure_uid_qgdylz="145">Record</SPAN> <SPAN closure_uid_qgdylz="146">sales data</SPAN><SPAN closure_uid_qgdylz="147">.</SPAN></td>
</tr>
<tr>
<td colspan="6" bgcolor="#CCCC99" class="whitetext13bold">Member Information</td>
</tr>
<tr>
<td width="16%">Member Search:</td>
<td width="23%"><input type="text" name="MemberID" id="MemberID" onKeyUp="searchOK(this);" /></td>
<td width="7%">Name :</td>
<td width="22%"><div id="area1"><input type="text" name="Name" id="Name" /><input type="hidden" name="MemberIDhid" id="MemberIDhid" /></div></td>
<td width="6%">Date :</td>
<td width="26%"><input name="dateselect" type="text" class = "box" id="dateselect" size="10" value="<? echo $today1;?>" style="color:#0000FF" />
<img src="../icons/carlenda.gif" width="18" height="18" onClick="openCalendar(dateselect,0,null,null);" />
<input name="time" type="hidden" value="<? echo $gettime; ?>"></td>
</tr>
<tr>
<td colspan="6" bgcolor="#CCCC99" class="whitetext13bold">Item Detail</td>
</tr>
<tr>
<td colspan="6">BillNumber ::
<input type="text" name="MemberID2" />
*</td>
</tr>
<tr>
<td colspan="6">
<table width="100%" border="1" cellpadding="0" cellspacing="0" class="bold" bordercolor="#669933" id="myTable" >
<input type = "hidden" name="checkboxcount" id="checkboxcount" value = "1"/>
<tbody>
<tr align="center" bgcolor="">
<td width="9%">No.</td>
<td width="8%">Amount</td>
<td width="10%">Code</td>
<td width="25%">Detail</td>
<td width="10%">Price</td>
<td width="17%">Total</td>
<td width="10%">PV</td>
<td width="10%">TotalPV</td>
</tr>
<tr>
<td align="center">
<input name="NO0" id="NO0" type="text" size="2" value="1" /></td>
<td><input type="text" name="Amount0" id="Amount0" size="2"/></td>
<!-- <td><input type="text" name="Code0" id="Code0" onBlur="checkOrder(this), checkOrder1(this), checkOrderPV (this), calTotal() , checkDis(this), sumTotal(), calDis(), sumcalTotal(), calVat(),sumPV(), addRow('myTable');" size="5" /></td>-->
<td><input type="text" name="Code0" id="Code0" onBlur="checkOrder(this), checkOrder1(this), checkOrderPV (this), calTotal() , calTotalPV() , checkDis(this), sumTotal(), calDis(), sumcalTotal(), calVat(),sumPV(),addRow('myTable');" size="5" /></td>
<td><div id="area2"><input type="text" name="Detail0" id="Detail0" size="30" /></div></td>
<td><div id="area3"><input type="text" name="Price" id="Price" size="5" /></div></td>
<td><input type="text" name="Total0" id="Total0" size="10" /></td>
<td><div id="area4"><input type="text" name="PV0" id="PV0" size="5" /></div></td>
<td ><INPUT TYPE="text" name="TotalPV0" id="TotalPV0" size="5" /> </td>
</tr>
</tbody></table></td></tr>
<tr>
<td colspan="6">
<table width="100%" border="0">
<tr>
<td colspan="5">TOTAL</td>
<td colspan="2"><input type="text" name="sumtotal" id="sumtotal" /> </td>
</tr>
<tr>
<td width="10%">Discount</td>
<td width="21%"><div id="area5"><input type="text" name="DiscountRate" id="DiscountRate" disabled/></div></td>
<td width="7%">%</td>
<td colspan="2"><input type="text" name="ValuesDis" id="ValuesDis" /></td>
<td colspan="2"><input type="text" name="SumTotal" id="SumTotal1" disabled /></td>
</tr>
<tr>
<td>Vat</td>
<td><input type="text" name="Vat" disabled value="7" size="10"/><input name="Vat" type="hidden" value="7"/></td>
<td>%</td>
<td width="21%"><input type="text" name="ValueVat" id="ValueVat" disabled /></td>
<td width="14%" align="right">PV</td>
<td colspan="2"><input type="text" name="SumPV" id="SumPV" disabled /></td>
</tr>
</table> </td></tr>
<tr align="center">
<td height="31" colspan="6">
<input type="submit" name="save" id="button" value="Save" style="background-image:url(../img/button_mid.png); color:#daeb73; font-family: Tahoma,MS Sans Serif, sans-serif; font-size: 13px; font-style: normal; font-weight: bold">
<input type="submit" name="button2" id="button2" value="Cancel" style="background-image:url(../img/button_mid.png); color:#daeb73; font-family: Tahoma,MS Sans Serif, sans-serif; font-size: 13px; font-style: normal; font-weight: bold"> </td>
</tr>
</table>
</form>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
<td width="19" align="left" valign="top"> </td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top" background="../template/img/summer_allbg.png" style="background-repeat:repeat-y" height="2"></td>
</tr>
<tr>
<td align="left" valign="top"><img src="../img/summer_allfooter.png" width="1024" height="54" /></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
<script type="text/javascript" src="jsscript/cal2.js" ></script>
<script type="text/javascript" src="jsscript/cal_conf2.js"></script>
<link rel="stylesheet" type="text/css" href="jsscript/calendar-mos.css">
<SCRIPT LANGUAGE="JavaScript" SRC="jsscript/calendar.js"></SCRIPT>
<script language="javascript">
function searchOK(id1){
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area1");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("Name") =req.responseText;
document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area1");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="mem.php?pop="+str;
url+="&id="+id1.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkOrder(code)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area2");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("Detail") =req.responseText;
document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area2");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="item.php?pop="+str;
url+="&id="+code.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkOrder1(code2)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area3");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("Price") =req.responseText;
// document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area3");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="price.php?pop="+str;
url+="&id="+code2.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkOrderPV(code3)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area4");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("PV") =req.responseText;
// document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area4");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="pv.php?pop="+str;
url+="&id="+code3.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkDis(code4)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area5");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("PV") =req.responseText;
// document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area5");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="dis.php?pop="+str;
url+="&id="+code4.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function addRow(id){
//alert("hi");
var checkcountobj = document.getElementById("checkboxcount");
var count = checkcountobj.value;
//alert("count "+count);
if(count == 'null' || count == ''){
count = 1;
}
count++;
checkcountobj.value = count;
//alert(count);
tabBody=document.getElementById(id).getElementsByTagName("TBODY")[0];
//alert(tabBody);
row=document.createElement("TR");
cell1 = document.createElement("TD");
cell2 = document.createElement("TD");
cell3 = document.createElement("TD");
cell4 = document.createElement("TD");
cell5 = document.createElement("TD");
cell6 = document.createElement("TD");
cell7 = document.createElement("TD");
cell8 = document.createElement("TD");
cell9 = document.createElement("TD");
textnode1=document.createElement("INPUT");
textnode1.setAttribute("type", "text");
textnode1.setAttribute("name", "NO"+count+"");
textnode1.setAttribute("id", "NO"+count+"");
textnode1.setAttribute("size", "2");
textnode1.setAttribute("value", count );
textnode2=document.createElement("INPUT");
textnode2.setAttribute("type", "text");
textnode2.setAttribute("name", "Amount"+count+"");
textnode2.setAttribute("id", "Amoun"+count+"");
textnode2.setAttribute("size", "2");
//textnode2.setAttribute('onblur', 'checkpostal(this)');
//textnode2.onblur = checkpostal;
//var textonblur = textnode2.onblur ;
//textonblur = checkpostal;
//textonblur.setAttribute(this);
textnode3=document.createElement("INPUT");
textnode3.setAttribute("type", "text");
textnode3.setAttribute("name", "Code"+count+"");
textnode3.setAttribute("id", "Code"+count+"");
textnode3.setAttribute("size", "5");
//textnode3.onblur = checkOrder(this);
//textnode3.onblur = checkOrder;
//textnode3.onblur.setAttribute(this);
textnode4=document.createElement("INPUT");
textnode4.setAttribute("type", "text");
textnode4.setAttribute("name", "Detail"+count+"");
textnode4.setAttribute("id", "Detail"+count+"");
textnode4.setAttribute("size", "30");
textnode5=document.createElement("INPUT");
textnode5.setAttribute("type", "text");
textnode5.setAttribute("name", "Price"+count+"");
textnode5.setAttribute("id", "Price"+count+"");
textnode5.setAttribute("size", "5");
textnode6=document.createElement("INPUT");
textnode6.setAttribute("type", "text");
textnode6.setAttribute("name", "Total"+count+"");
textnode6.setAttribute("id", "Total"+count+"");
textnode6.setAttribute("size", "10");
textnode7=document.createElement("INPUT");
textnode7.setAttribute("type", "text");
textnode7.setAttribute("name", "PV"+count+"");
textnode7.setAttribute("id", "PV"+count+"");
textnode7.setAttribute("size", "5");
textnode8=document.createElement("INPUT");
textnode8.setAttribute("type", "text");
textnode8.setAttribute("name", "TotalPV"+count+"");
textnode8.setAttribute("id", "TotalPV"+count+"");
textnode8.setAttribute("size", "2");
textnode9=document.createElement("INPUT");
textnode9.setAttribute("type", "button");
textnode9.setAttribute("name", "Remove");
textnode9.setAttribute("value", "Remove");
textnode9.setAttribute("id", "remove"+count+"");
textnode9.onclick = removeRowFromTable;
cell1.appendChild(textnode1);
cell2.appendChild(textnode2);
cell3.appendChild(textnode3);
cell4.appendChild(textnode4);
cell5.appendChild(textnode5);
cell6.appendChild(textnode6);
cell7.appendChild(textnode7);
cell8.appendChild(textnode8);
cell9.appendChild(textnode9);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell4);
row.appendChild(cell5);
row.appendChild(cell6);
row.appendChild(cell7);
row.appendChild(cell8);
row.appendChild(cell9);
tabBody.appendChild(row);
}
function removeRowFromTable()
{
var tbl = document.getElementById('myTable');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
function check()
{
//alert('1111');
}
function openCalendar(obj,isAge,objAgeY,objAgeM)
{
var arr = window.showModalDialog("../calendar/calendar.html", null, "scroll:no; status:no; help:no; dialogWidth:200px; dialogHeight:200px");
if(arr != null)
{
obj.value = arr["date"]+ "/" + arr["month"] + "/" + arr["year"];
if(isAge == 1)
{
//คำนวณอายุ
calAge(arr["date"],arr["month"],arr["year"],objAgeY,objAgeM);
}
}
else
{
obj.value = "";
}
}
/*{
alert('1');
var total = document.getElementById('Total0');
var amount = parseFloat(document.totalfrm.price.value);
//alert(amount);
var aaaa = document.getElementById('Price111').value;
// alert(aaaa.value);
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
}*/
function calTotal(){
var Amount0 =parseFloat(document.payment.Amount.value);
var Price0 = parseFloat(document.payment.Price.value);
document.payment.Total0.value=Amount0*Price0;
}
function calTotalPV()
{
var totalpv = document.getElementById('TotalPV0');
var amount = document.getElementById('Amount0').value;
//alert(amount);
var bbbb = document.getElementById('PV0');
var total1 = amount*bbbb.value ;
totalpv.value = total1;
}
function sumTotal()
{
document.getElementById('sumtotal').value = document.getElementById('Total0').value;
}
function calDis()
{
var sumtotal = document.getElementById('sumtotal').value;
alert('The amount of tax.');
var disrate = document.getElementById('DiscountRate').value;
var Valdis = document.getElementById('ValuesDis');
Valdis.value = (parseInt(disrate)/100)* (parseInt(sumtotal));
}
function sumcalTotal()
{
var valuesdis = document.getElementById('ValuesDis').value;
//alert(parseInt(valuesdis));
var sumtotal = document.getElementById('sumtotal').value;
document.getElementById('SumTotal1').value = (parseInt(sumtotal)) - (parseInt(valuesdis));
}
function calVat()
{
var sumtotal = document.getElementById('SumTotal1').value;
var valvat = (7/100)*(parseInt(sumtotal));
document.getElementById('ValueVat').value = valvat.toFixed(2);
}
function sumPV()
{
var pv = document.getElementById('TotalPV0').value;
document.getElementById('SumPV').value = pv;
}
function addTable_home_use()
{
var tbl = document.getElementById('myTable');
var lastRow = tbl.rows.length;
var num_u = new Number(lastRow)-1;
var row = tbl.insertRow(lastRow);
var cellRight1 = row.insertCell(0);
var text="";
text +=" <table width='761' > ";
text +=" <tr >";
text +=" <td align='center'>";
text +=" <input name='NO["+num_u+"]' id='NO["+num_u+"]' type='text' size='2' value="+num_u+" />";
text +=" </td>";
text +=" </tr>";
text +=" </table>";
//var elx = document.createElement('span');
// elx.innerHTML ="<div onclick='removeRowFromTable_home_use();' align='center'><a href='#'><img src='images/del.gif' border='0' size='8'></a></div> ";
//el.onkeypress = keyPressTest;
cellRight1.appendChild(elx);
var cellRight2 = row.insertCell(1);
var elx2 = document.createElement('span');
elx2.innerHTML ="<div id='aa'>"+text+"</div>";
cellRight2.appendChild(elx2);
}
function removeRowFromTable_home_use()
{
var tbl = document.getElementById('myTable');
var lastRow = tbl.rows.length;
tbl.deleteRow(lastRow - 1);
var xx = document.getElementById('numIndex').value;
document.getElementById('numIndex').value = new Number(xx)-1;
}
</script>
Date :
2012-05-22 10:32:56
By :
computerpsu031
ข้อโทษนะคับ Code ด้านบน Coppy มาผิด
Code (PHP)
<?
//include("../header.html");
//include ("top_menu.php");
require_once("../function.class.php");
require_once("../html.class.php");
$today = getdate();
$date_H = date(H);
$date_i = date(i);
$date_s = date(s);
$date_H1 = $date_H - 1 ;
$gettime = $date_H1.':'.$date_i.':'.$date_s;
$d = $today["mday"];
if($d <10)
{
$d1 = '0'.$d;
}
else
{
$d1 = $d;
}
$m = $today["mon"];
if($m <10)
{
$m1 = '0'.$m;
}
else
{
$m1 = $m;
}
$y = $today["year"];
$y1 = ((int)$y)+543;
//$y5 = ((int)$y1)+5;
$today1 = $d.'/'.$m.'/'.$y;
?>
<?
if($_POST['save'] != "")
{
$dbconn = getDB_Connection();
$dateselect = $_POST['dateselect'];
$dateselect1 = getDate2Pg($dateselect);
$sql_ins = 'INSERT INTO orders (bill_no, mid, order_date, paid, order_time,products_cost ) VALUES(\''.$_POST['MemberID2'].'\', \''.$_POST['MemberIDhid'].'\', '.$dateselect1.', 1, \''.$_POST['time'].'\', \''.$_POST['sumtotal'].'\' )';
mysql_select_db('summer', $dbconn);
mysql_query("SET NAMES 'utf8'");
$res_ins = mysql_query($sql_ins, $dbconn);
$sql_max = 'SELECT MAX(order_id) AS max_order FROM orders ';
mysql_select_db('summer', $dbconn);
$query_max = mysql_query($sql_max,$dbconn);
$data_max = mysql_fetch_array($query_max);
$max = $data_max['max_order'];
$no = $_POST['NO'];
$xx = count($no);
//for ($i=0;$i<$xx;$i++)
// {
echo $sql_item = 'INSERT INTO orders_items (order_id, serialno, proname, qty, uprice, PV) VALUES(\''.$max.'\', \''.$_POST['Code0'].'\',\''.$_POST['Detail0'].'\', \''.$_POST['Amount'].'\', \''.$_POST['Price0'].'\', \''.$_POST['TotalPV0'].'\' )';
mysql_select_db('summer', $dbconn);
mysql_query("SET NAMES 'utf8'");
$res_item = mysql_query($sql_item, $dbconn);
// }
?>
<script language="javascript">//alert('Save Successfull');</script>
<?
}
?>
<!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"><!-- InstanceBegin template="/Templates/main_admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Summer of 1955</title>
<!-- InstanceEndEditable -->
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
</script>
<link href="../css/summer.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body background="../img/summer_bg.jpg" style="background-repeat:repeat-x">
<table align="center" width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50" align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top"><img src="../img/summer_indexhead.png" width="1024" height="71" /></td>
</tr>
<tr>
<td align="left" valign="top" background="../img/summer_allbg.png" style="background-repeat:repeat-y" height="2"></td>
</tr
><tr>
<td align="left" valign="top" background="../img/summer_allbg.png" style="background-repeat:repeat-y"><table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17" align="left" valign="top"> </td>
<td width="230" align="left" valign="top" bgcolor="#eff0ea"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="100" align="center" valign="top" style="padding-top:50px"><img src="../img/membermenu.jpg" width="160" height="160" /></td>
</tr>
<tr>
<td style="padding-left:30px"> </td>
</tr>
<!--<tr>
<td style="padding-left:30px"><a href="#" class="sidemenulink">• Profile</a></td>
</tr>
<tr>
<td align="left" valign="top" class="blacktext11" style="padding-left:30px">...........................................</td>
</tr>
<tr>
<td style="padding-left:30px"><a href="#" class="sidemenulink">• Statement</a></td>
</tr>
<tr>
<td class="blacktext11" style="padding-left:30px">...........................................</td>
</tr>
<tr>
<td style="padding-left:30px"><a href="#" class="sidemenulink">• Bonus</a></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>-->
<tr>
<td> </td>
</tr>
</table></td>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="760" height="48" align="left" valign="bottom" bgcolor="#eff0ea"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="50" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="member_search.php" target="_parent" class="greenlink">Member</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="80" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="payment.php" target="_parent" class="greenlink">Payment</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="loi_form.php" target="_parent" class="greenlink">LOI Form</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="loi_approve.php" target="_parent" class="greenlink">LOI Approve</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="add_bonus_rate.php" target="_parent" class="greenlink">System Setup</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<td width="10" align="left" valign="top"> </td>
<td width="19" align="left" valign="top"><img src="../img/summer_menubgleft.jpg" width="19" height="35" /></td>
<td width="90" align="center" valign="middle" background="../img/summer_menubgmid.jpg" class="whitetext13bold" style="background-repeat:repeat-x"><a href="logout.php" target="_parent" class="greenlink">Logout</a></td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgright.jpg" width="19" height="35" /></td>
<!-- <td width="19" align="left" valign="top"><img src="../img/summer_menubgleftgrey.jpg" width="19" height="35" /></td>
<td width="160" align="center" valign="middle" background="img/summer_menubgmidgrey.jpg" class="whitetext13bold" style="background-repeat:repeat-x">For Summer's Members</td>
<td width="19" align="right" valign="top"><img src="../img/summer_menubgrightgrey.jpg" width="19" height="35" /></td>-->
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top"><img src="../img/memberpic.jpg" width="758" height="270" /></td>
</tr>
<tr>
<td> <!-- InstanceBeginEditable name="EditRegion5" -->
<form name="payment" method="post" action=""><table width="90%" border="0 " class="blackbold" align="center" >
<tr>
<td colspan="6" align="center" bgcolor="#9fad53" class="whitetext13bold"><SPAN closure_uid_qgdylz="145">Record</SPAN> <SPAN closure_uid_qgdylz="146">sales data</SPAN><SPAN closure_uid_qgdylz="147">.</SPAN></td>
</tr>
<tr>
<td colspan="6" bgcolor="#CCCC99" class="whitetext13bold">Member Information</td>
</tr>
<tr>
<td width="16%">Member Search:</td>
<td width="23%"><input type="text" name="MemberID" id="MemberID" onKeyUp="searchOK(this);" /></td>
<td width="7%">Name :</td>
<td width="22%"><div id="area1"><input type="text" name="Name" id="Name" /><input type="hidden" name="MemberIDhid" id="MemberIDhid" /></div></td>
<td width="6%">Date :</td>
<td width="26%"><input name="dateselect" type="text" class = "box" id="dateselect" size="10" value="<? echo $today1;?>" style="color:#0000FF" />
<img src="../icons/carlenda.gif" width="18" height="18" onClick="openCalendar(dateselect,0,null,null);" />
<input name="time" type="hidden" value="<? echo $gettime; ?>"></td>
</tr>
<tr>
<td colspan="6" bgcolor="#CCCC99" class="whitetext13bold">Item Detail</td>
</tr>
<tr>
<td colspan="6">BillNumber ::
<input type="text" name="MemberID2" />
*</td>
</tr>
<tr>
<td colspan="6">
<table width="100%" border="1" cellpadding="0" cellspacing="0" class="bold" bordercolor="#669933" id="myTable" >
<input type = "hidden" name="checkboxcount" id="checkboxcount" value = "1"/>
<tbody>
<tr align="center" bgcolor="">
<td width="9%">No.</td>
<td width="8%">Amount</td>
<td width="10%">Code</td>
<td width="25%">Detail</td>
<td width="10%">Price</td>
<td width="17%">Total</td>
<td width="10%">PV</td>
<td width="10%">TotalPV</td>
</tr>
<tr>
<td align="center">
<input name="NO0" id="NO0" type="text" size="2" value="1" /></td>
<td><input type="text" name="Amount0" id="Amount0" size="2"/></td>
<!-- <td><input type="text" name="Code0" id="Code0" onBlur="checkOrder(this), checkOrder1(this), checkOrderPV (this), calTotal() , checkDis(this), sumTotal(), calDis(), sumcalTotal(), calVat(),sumPV(), addRow('myTable');" size="5" /></td>-->
<td><input type="text" name="Code0" id="Code0" onBlur="checkOrder(this), checkOrder1(this), checkOrderPV (this), calTotal() , calTotalPV() , checkDis(this), sumTotal(), calDis(), sumcalTotal(), calVat(),sumPV(),addRow('myTable');" size="5" /></td>
<td><div id="area2"><input type="text" name="Detail0" id="Detail0" size="30" /></div></td>
<td><div id="area3"><input type="text" name="Price" id="Price" size="5" /></div></td>
<td><input type="text" name="Total0" id="Total0" size="10" /></td>
<td><div id="area4"><input type="text" name="PV0" id="PV0" size="5" /></div></td>
<td ><INPUT TYPE="text" name="TotalPV0" id="TotalPV0" size="5" /> </td>
</tr>
</tbody></table></td></tr>
<tr>
<td colspan="6">
<table width="100%" border="0">
<tr>
<td colspan="5">TOTAL</td>
<td colspan="2"><input type="text" name="sumtotal" id="sumtotal" /> </td>
</tr>
<tr>
<td width="10%">Discount</td>
<td width="21%"><div id="area5"><input type="text" name="DiscountRate" id="DiscountRate" disabled/></div></td>
<td width="7%">%</td>
<td colspan="2"><input type="text" name="ValuesDis" id="ValuesDis" /></td>
<td colspan="2"><input type="text" name="SumTotal" id="SumTotal1" disabled /></td>
</tr>
<tr>
<td>Vat</td>
<td><input type="text" name="Vat" disabled value="7" size="10"/><input name="Vat" type="hidden" value="7"/></td>
<td>%</td>
<td width="21%"><input type="text" name="ValueVat" id="ValueVat" disabled /></td>
<td width="14%" align="right">PV</td>
<td colspan="2"><input type="text" name="SumPV" id="SumPV" disabled /></td>
</tr>
</table> </td></tr>
<tr align="center">
<td height="31" colspan="6">
<input type="submit" name="save" id="button" value="Save" style="background-image:url(../img/button_mid.png); color:#daeb73; font-family: Tahoma,MS Sans Serif, sans-serif; font-size: 13px; font-style: normal; font-weight: bold">
<input type="submit" name="button2" id="button2" value="Cancel" style="background-image:url(../img/button_mid.png); color:#daeb73; font-family: Tahoma,MS Sans Serif, sans-serif; font-size: 13px; font-style: normal; font-weight: bold"> </td>
</tr>
</table>
</form>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
<td width="19" align="left" valign="top"> </td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top" background="../template/img/summer_allbg.png" style="background-repeat:repeat-y" height="2"></td>
</tr>
<tr>
<td align="left" valign="top"><img src="../img/summer_allfooter.png" width="1024" height="54" /></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
<script type="text/javascript" src="jsscript/cal2.js" ></script>
<script type="text/javascript" src="jsscript/cal_conf2.js"></script>
<link rel="stylesheet" type="text/css" href="jsscript/calendar-mos.css">
<SCRIPT LANGUAGE="JavaScript" SRC="jsscript/calendar.js"></SCRIPT>
<script language="javascript">
function searchOK(id1){
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area1");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("Name") =req.responseText;
document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area1");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="mem.php?pop="+str;
url+="&id="+id1.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkOrder(code)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area2");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("Detail") =req.responseText;
document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area2");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="item.php?pop="+str;
url+="&id="+code.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkOrder1(code2)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area3");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("Price") =req.responseText;
// document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area3");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="price.php?pop="+str;
url+="&id="+code2.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkOrderPV(code3)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area4");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("PV") =req.responseText;
// document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area4");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="pv.php?pop="+str;
url+="&id="+code3.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function checkDis(code4)
{
var req;
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("Browser error");
return false;
}
req.onreadystatechange=function()
{
if(req.readyState==4){
var resultarea=document.getElementById("area5");
resultarea.innerHTML=req.responseText;
//]alert(req.responseText);
document.getElementById("PV") =req.responseText;
// document.getElementById("MemberIDhid") = req.responseText ;
}else {
var resultarea=document.getElementById("area5");
resultarea.innerHTML="กรุณารอสักครู่.....";
}
}
str=Math.random()
var url="dis.php?pop="+str;
url+="&id="+code4.value;
// alert(url);
req.open("GET",url,true);
req.send(null);
}
function addRow(id){
//alert("hi");
var checkcountobj = document.getElementById("checkboxcount");
var count = checkcountobj.value;
//alert("count "+count);
if(count == 'null' || count == ''){
count = 1;
}
count++;
checkcountobj.value = count;
//alert(count);
tabBody=document.getElementById(id).getElementsByTagName("TBODY")[0];
//alert(tabBody);
row=document.createElement("TR");
cell1 = document.createElement("TD");
cell2 = document.createElement("TD");
cell3 = document.createElement("TD");
cell4 = document.createElement("TD");
cell5 = document.createElement("TD");
cell6 = document.createElement("TD");
cell7 = document.createElement("TD");
cell8 = document.createElement("TD");
cell9 = document.createElement("TD");
textnode1=document.createElement("INPUT");
textnode1.setAttribute("type", "text");
textnode1.setAttribute("name", "NO"+count+"");
textnode1.setAttribute("id", "NO"+count+"");
textnode1.setAttribute("size", "2");
textnode1.setAttribute("value", count );
textnode2=document.createElement("INPUT");
textnode2.setAttribute("type", "text");
textnode2.setAttribute("name", "Amount"+count+"");
textnode2.setAttribute("id", "Amoun"+count+"");
textnode2.setAttribute("size", "2");
//textnode2.setAttribute('onblur', 'checkpostal(this)');
//textnode2.onblur = checkpostal;
//var textonblur = textnode2.onblur ;
//textonblur = checkpostal;
//textonblur.setAttribute(this);
textnode3=document.createElement("INPUT");
textnode3.setAttribute("type", "text");
textnode3.setAttribute("name", "Code"+count+"");
textnode3.setAttribute("id", "Code"+count+"");
textnode3.setAttribute("size", "5");
//textnode3.onblur = checkOrder(this);
//textnode3.onblur = checkOrder;
//textnode3.onblur.setAttribute(this);
textnode4=document.createElement("INPUT");
textnode4.setAttribute("type", "text");
textnode4.setAttribute("name", "Detail"+count+"");
textnode4.setAttribute("id", "Detail"+count+"");
textnode4.setAttribute("size", "30");
textnode5=document.createElement("INPUT");
textnode5.setAttribute("type", "text");
textnode5.setAttribute("name", "Price"+count+"");
textnode5.setAttribute("id", "Price"+count+"");
textnode5.setAttribute("size", "5");
textnode6=document.createElement("INPUT");
textnode6.setAttribute("type", "text");
textnode6.setAttribute("name", "Total"+count+"");
textnode6.setAttribute("id", "Total"+count+"");
textnode6.setAttribute("size", "10");
textnode7=document.createElement("INPUT");
textnode7.setAttribute("type", "text");
textnode7.setAttribute("name", "PV"+count+"");
textnode7.setAttribute("id", "PV"+count+"");
textnode7.setAttribute("size", "5");
textnode8=document.createElement("INPUT");
textnode8.setAttribute("type", "text");
textnode8.setAttribute("name", "TotalPV"+count+"");
textnode8.setAttribute("id", "TotalPV"+count+"");
textnode8.setAttribute("size", "2");
textnode9=document.createElement("INPUT");
textnode9.setAttribute("type", "button");
textnode9.setAttribute("name", "Remove");
textnode9.setAttribute("value", "Remove");
textnode9.setAttribute("id", "remove"+count+"");
textnode9.onclick = removeRowFromTable;
cell1.appendChild(textnode1);
cell2.appendChild(textnode2);
cell3.appendChild(textnode3);
cell4.appendChild(textnode4);
cell5.appendChild(textnode5);
cell6.appendChild(textnode6);
cell7.appendChild(textnode7);
cell8.appendChild(textnode8);
cell9.appendChild(textnode9);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell4);
row.appendChild(cell5);
row.appendChild(cell6);
row.appendChild(cell7);
row.appendChild(cell8);
row.appendChild(cell9);
tabBody.appendChild(row);
}
function removeRowFromTable()
{
var tbl = document.getElementById('myTable');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
function check()
{
//alert('1111');
}
function openCalendar(obj,isAge,objAgeY,objAgeM)
{
var arr = window.showModalDialog("../calendar/calendar.html", null, "scroll:no; status:no; help:no; dialogWidth:200px; dialogHeight:200px");
if(arr != null)
{
obj.value = arr["date"]+ "/" + arr["month"] + "/" + arr["year"];
if(isAge == 1)
{
//คำนวณอายุ
calAge(arr["date"],arr["month"],arr["year"],objAgeY,objAgeM);
}
}
else
{
obj.value = "";
}
}
function calTotal()
{
alert('1');
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
//alert(amount);
var aaaa = document.getElementById('Price111').value;
// alert(aaaa.value);
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
}
function calTotalPV()
{
var totalpv = document.getElementById('TotalPV0');
var amount = document.getElementById('Amount0').value;
alert(amount);
var bbbb = document.getElementById('PV0');
var total1 = amount*bbbb.value ;
totalpv.value = total1;
}
function sumTotal()
{
document.getElementById('sumtotal').value = document.getElementById('Total0').value;
}
function calDis()
{
var sumtotal = document.getElementById('sumtotal').value;
alert('The amount of tax.');
var disrate = document.getElementById('DiscountRate').value;
var Valdis = document.getElementById('ValuesDis');
Valdis.value = (parseInt(disrate)/100)* (parseInt(sumtotal));
}
function sumcalTotal()
{
var valuesdis = document.getElementById('ValuesDis').value;
//alert(parseInt(valuesdis));
var sumtotal = document.getElementById('sumtotal').value;
document.getElementById('SumTotal1').value = (parseInt(sumtotal)) - (parseInt(valuesdis));
}
function calVat()
{
var sumtotal = document.getElementById('SumTotal1').value;
var valvat = (7/100)*(parseInt(sumtotal));
document.getElementById('ValueVat').value = valvat.toFixed(2);
}
function sumPV()
{
var pv = document.getElementById('TotalPV0').value;
document.getElementById('SumPV').value = pv;
}
function addTable_home_use()
{
var tbl = document.getElementById('myTable');
var lastRow = tbl.rows.length;
var num_u = new Number(lastRow)-1;
var row = tbl.insertRow(lastRow);
var cellRight1 = row.insertCell(0);
var text="";
text +=" <table width='761' > ";
text +=" <tr >";
text +=" <td align='center'>";
text +=" <input name='NO["+num_u+"]' id='NO["+num_u+"]' type='text' size='2' value="+num_u+" />";
text +=" </td>";
text +=" </tr>";
text +=" </table>";
//var elx = document.createElement('span');
// elx.innerHTML ="<div onclick='removeRowFromTable_home_use();' align='center'><a href='#'><img src='images/del.gif' border='0' size='8'></a></div> ";
//el.onkeypress = keyPressTest;
cellRight1.appendChild(elx);
var cellRight2 = row.insertCell(1);
var elx2 = document.createElement('span');
elx2.innerHTML ="<div id='aa'>"+text+"</div>";
cellRight2.appendChild(elx2);
}
function removeRowFromTable_home_use()
{
var tbl = document.getElementById('myTable');
var lastRow = tbl.rows.length;
tbl.deleteRow(lastRow - 1);
var xx = document.getElementById('numIndex').value;
document.getElementById('numIndex').value = new Number(xx)-1;
}
</script>
Date :
2012-05-22 10:35:40
By :
computerpsu031
function calTotal()
647.{
$("#Total0").val( parseFloat($("#Amount0").val()) * parseFloat($("#Price").val()) );
658.}
Date :
2012-05-22 11:23:22
By :
sakuraei
มันเป็นเพราะอะไรนะคับพี่
Date :
2012-05-22 13:40:32
By :
computerpsu031
ไม่แน่ใจครับ แต่ที่พี่แก้ไขให้ เอาไปทดสอบหรือยัง
function calTotal()
647.{
$("#Total0").val( parseFloat($("#Amount0").val()) * parseFloat($("#Price").val()) );
658.}
Date :
2012-05-22 13:42:38
By :
sakuraei
รบกวนพี่ช่วยอธิบายหน่อยได้หรอเปล่าคับ ในตัวของ code นะคับ และผมผิดตรงไหนนะคับ แล้วควรแก้อย่างไร ให้ลบ function calTotalPV ทิ้่ง แล้วใส่ตัวนี้ไปแทนหรอคับ
Date :
2012-05-22 13:48:46
By :
computerpsu031
เอาไปทดสอบแล้วนะคับมันไม่ทำงานเลย นะคับ
Date :
2012-05-22 13:52:04
By :
computerpsu031
เพิ่มบรรทัดนี้
<script src="http://code.jquery.com/jquery-latest.js"></script>
ก่อน </head>
Date :
2012-05-22 13:57:16
By :
sakuraei
Code (JavaScript)
function calTotal()
{
$("#Total0").val( parseFloat($("#Amount0").val()) * parseFloat($("#Price").val()) );
// alert('กรอกข้อมูลสำเร้จค่ะ');
var total = document.getElementById('Total0');
var amount = document.getElementById('Amount0').value;
//alert(amount);
var aaaa = document.getElementById('Price111').value;
// alert(aaaa.value);
var total1 = parseFloat(amount)*parseFloat(aaaa) ;
total.value = total1;
}
ค่าในส่วนของ Total จะออกมาเป็น NaN
Date :
2012-05-22 14:01:11
By :
computerpsu031
เอาแค่นี้พอครับ
Code (PHP)
function calTotal()
{
var result = parseFloat($("#Amount0").val()) * parseFloat($("#Price").val());
$("#Total0").val( result);
}
ตกลงว่าตอนนี้ใช้ id="Price" หรือ id="Price1111" กันแน่
Date :
2012-05-22 14:06:21
By :
sakuraei
Code (PHP)
<?
require_once("../function.class.php");
require_once("../html.class.php");
//header("Content-Type: text/html; charset=TIS-620");
$id = $_GET['id'];
$dbconn = getDB_Connection();
$sql = "SELECT priducts.price FROM priducts WHERE priducts.code = '$id' ";
mysql_select_db('summer', $dbconn);
$query = mysql_query($sql,$dbconn) ;
while($data = mysql_fetch_array($query))
{
//$detail = $data['name_eng'];
$price = $data['price'];
}
//echo $name;
?>
<input type="text" name="Price0" id="Price111" size="5" value="<? echo $price;?>" />
มันรับค่ามาจากหน้า price.php นะคับ
Date :
2012-05-22 14:09:01
By :
computerpsu031
ผลการรัน ของ Code จะได้เป็น total มีค่าที่ปรากฎใน textbox =NaN
Date :
2012-05-22 14:11:47
By :
computerpsu031
งั้นเปลี่ยนเป็น
Code (PHP)
function calTotal()
{
var result = parseFloat($("#Amount0").val()) * parseFloat($("#Price111").val());
$("#Total0").val( result);
}
ทดสอบแล้วแจ้งผลด้วยน่ะ
Date :
2012-05-22 14:15:11
By :
sakuraei
ผลการรันจาก Code
Code (JavaScript)
function calTotal()
{
var result = parseFloat($("#Amount0").val()) * parseFloat($("#Price111").val());
$("#Total0").val( result);
}
Date :
2012-05-22 14:17:44
By :
computerpsu031
ผมน่าแปลกว่าที่ทำไม เราต้องใส่ alert บน code ด้วยนะคับ
ซึ่ง code นี้ก็รันผ่านและได้คำตอบที่ถูกต้อง
alert('11');
var result = parseFloat($("#Amount0").val()) * parseFloat($("#Price111").val());
$("#Total0").val( result);
เพียงแต่ให้มี alert ก่อนการทำงานเท่านั้นเอง ผมเลย งง เลย ทำไมต้องมี alert
Date :
2012-05-22 14:21:19
By :
computerpsu031
Code (PHP)
function calTotal()
{
alert($("input#Amount0").val()+"/"+$("input#Price111").val());
var result = parseFloat($("input#Amount0").val()) * parseFloat($("input#Price111").val());
$("input#Total0").val( result);
}
Date :
2012-05-22 14:23:40
By :
sakuraei
คือพี่คับ ผมไม่อยากใ่ีห้มี alert นะคับ ให้่มันทำการคำนวนอัตโนมัติเลย นะคับ แบบโคดที่พี่ให้มา แบบนั้นก็ยังมีการ alert อยู่
Date :
2012-05-22 14:28:21
By :
computerpsu031
แค่อยากให้จับภาพหน้าจอมาให้ดูหน่อย ว่าค่าที่มัน alert มาเนี่ยถูกมั๊ย
แล้วเราค่อยเอา alert ออกทีหลัง
Date :
2012-05-22 14:34:42
By :
sakuraei
ผลของการรันนะคับ
Date :
2012-05-22 15:57:02
By :
computerpsu031
alert ครั้งแรก Price111 มีค่าเป็น undefined
เลยทำให้การคำนวนไม่ถูกต้อง
Date :
2012-05-22 16:15:21
By :
sakuraei
นั้นผมควรเช็คตรงไหนนะคับ
Date :
2012-05-22 16:17:20
By :
computerpsu031
ควรทำอย่างไร พี่ช่วยแนะนำให้หน่อยนะคับ
Date :
2012-05-22 16:17:49
By :
computerpsu031
ต้องใช้เวลาไล่โค้ดดู ซักพักใหญ่ล่ะน่ะ
Date :
2012-05-22 16:39:47
By :
sakuraei
ช่วยด้วยนะคับพี่ ผมปวดหัวมากๆเลย ไม่รู้จะแก้อย่างไรแล้ว มันหาทางไม่ไ้ดจริงๆ ผมไม่เข้าใจ่วา ทำไมต้องมีการ alert นะคับ เวลาจะ ดักจับ Error ของ javascript ก็หาไม่เจอ
Date :
2012-05-22 16:52:41
By :
computerpsu031
ใครก็ได้ช่วยหน่อยคับ
Date :
2012-05-23 09:52:57
By :
computerpsu031
...
Date :
2012-05-23 15:35:26
By :
computerpsu031
Load balance : Server 04