|
|
|
ต้องการเอา textbox=pvalue textbox=u_phone textbox=total_phone ออก แล้วเพิ่ม textox ชื่อ total _room |
|
|
|
|
|
|
|
ต้องการเอา textbox=pvalue textbox=u_phone textbox=total_phone ออก แล้วเพิ่ม textox ชื่อ total _room ซึ่งรับค่าจากฐานขข้อมูล $value_room แล้วเอาผลรวมทั้งหมดแสดงใน be_total คือลองทำดูแล้วแต่มันทำไม่ได้นะค่ะ ช่วยหน่อยนะค่ะ
<script type="text/javascript">
function addCommas(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
//*define object "Bill"
function Bill(){
//get form value
var unit = {
'water' : document.form2.wvalue.value,
'fire' : document.form2.fvalue.value,
'phone' : document.form2.pvalue.value
}
var rate = {
'water' : document.form2.u_water.value,
'fire' : document.form2.u_fire.value,
'phone' : document.form2.u_phone.value
}
//private function
this.calc = function(unit, rate){
unit = parseFloat(unit);
rate = parseFloat(rate);
if(!unit || !rate){return 0;}
return unit * rate;
}
//public properties
this.water = this.calc(unit['water'],rate['water']);
this.fire = this.calc(unit['fire'],rate['fire']);
this.phone = this.calc(unit['phone'],rate['phone']);
}
function calcBill(){
var bill = new Bill();
document.form2.total_water.value = addCommas(bill.water.toFixed(2));
document.form2.total_fire.value = addCommas(bill.fire.toFixed(2));
document.form2.total_phone.value = addCommas(bill.phone.toFixed(2));
document.form2.be_total.value = addCommas((bill.water + bill.fire + bill.phone).toFixed(2));
}
</script>
<style type="text/css">
<!--
.style6 {font-weight: bold; font-style: italic; font-size: 16px;}
.style6 {color: #000080}
.style13 {color: #517dbf;
font-weight: bold;
}
.style8 {color: #FFFFFF;
font-size: 16px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
a:link {
color: #517DBF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #517DBF;
}
a:hover {
text-decoration: none;
color: #FFFFFF;
}
a:active {
text-decoration: none;
color: #517DBF;
}
-->
</style>
</head>
<body>
<table width="90%" border="0" cellpadding="1" bgcolor="#66CCCC" align="center">
<tr valign="top">
<td width="82%" bgcolor="#EBF0F9"><form id="form1" name="form1" method="post" action="">
<p align="center">ª×èÍ·Õèµéͧ¡Òäé¹ËÒ
<select name="fields">
<option value="<?echo "$fields";?>"> </option>
<option value="roomno">ËÁÒÂàÅ¢Ëéͧ</option>
<option value="name">ª×èÍ - ¹ÒÁÊ¡ØÅ</option>
</select>
¨Ò¡ Filed
<input type="text" name="keyword" value="<? echo"$keyword"; ?>" />
<input type="submit" name="Submit" value="¤é¹ËÒ" />
</p>
<p align="center">
<?
if (empty($fields) or empty($fields))
{
echo"¡ÃسÒàÅ×Í¡ÃÒ¡Òäé¹ËÒ ´éǤÃѺ";
exit();
}
else
{
$host="localhost";
$username="root";
$password="";
$db="hotelmis";
$tb="reser";
mysql_connect( $host,$username,$password) or die ("µÔ´µè͡Ѻ°Ò¹¢éÍÁÙÅ Mysql äÁèä´é ");
mysql_select_db($db) or die("àÅ×Í¡°Ò¹¢éÍÁÙÅäÁèä´é"); /* ·Ó¡ÒÃàÅ×Í¡°Ò¹¢éÍÁÙÅ¡è͹ */
$sql="SELECT * FROM $tb where $fields like '%$keyword%' limit 0,1";
mysql_query("SET NAMES 'tis620'");
$db_query=mysql_db_query($db,$sql);
$num_rows=mysql_num_rows($db_query); /* ¹Ñº Reccord ·Õ辺 */
if(empty($num_rows)) /* µÃǨÊͺÇèÒÁÕÍÂÙèËÃ×ÍÂѧ */
{
echo"<center><br>äÁ辺¢éÍÁÙÅ ¡Òúѹ·Ö¡¢éÍÁÙŤèÒãªé¨èÒ¢ͧËéͧ <b>$keyword</b> <b> </center>";
exit();
}
else
{
?>
</p>
<div align="center">
<p><? echo " áÊ´§ÃÒ¡Òäé¹ËÒ ¨Ò¡ $keyword"; ?> <br />
<br />
</p>
</div>
<p>
<?
$a=0;
while($a < $num_rows)
{
$result = mysql_fetch_array($db_query);
$id=$result[id];
$password=$result[password];
$date=$result[date];
$name=$result[name];
$roomno=$result[roomno];
$email=$result[email];
$tel=$result[tel];
$value_room=$result[value_room];
?>
</p>
<p>
<?
$a++;
}
}
}
?>
</p>
</form>
<form id="form2" name="form2" method="post" action="unitinsert.php">
<p> </p>
<table width="93%" border="0" align="center" cellpadding="1" bordercolor="#1E3C7B" bgcolor="#1E3C7B">
<tr>
<td bgcolor="#EBF0F9"><table width="100%" height="125" align="center">
<tr>
<td bgcolor="#1e3c7b"><span class="style14">¤èÒâ·ÃÈѾ·ì </span></td>
<td bgcolor="#1e3c7b"><span class="style15"></span></td>
<td bgcolor="#1e3c7b"><span class="style15"><strong>¤èÒ¹éÓ</strong></span></td>
<td bgcolor="#1e3c7b"><span class="style15"></span></td>
<td bgcolor="#1e3c7b"><span class="style15"><strong>¤èÒä¿</strong></span></td>
<td bgcolor="#1e3c7b"><span class="style15"></span></td>
</tr>
<tr>
<td width="17%" bgcolor="#EBF0F9"><div align="right"><strong>¤èÒËéͧ</strong>:</div></td>
<td width="11%" bgcolor="#EBF0F9"><div align="left">
<input type='pvalue' id='pvalue' name='pvalue' value='' onkeyup='phone1()' size="10" />
</div></td>
<td width="22%" bgcolor="#EBF0F9"><div align="right"><strong>¤èÒ¹éÓ : </strong></div></td>
<td width="14%" bgcolor="#EBF0F9"><div align="left">
<input name="wvalue" type="text" id="wvalue"onkeyup='water()' size="10" />
</div></td>
<td width="14%" bgcolor="#EBF0F9"><div align="right"><strong>¤èÒä¿:</strong></div></td>
<td width="22%" bgcolor="#EBF0F9"><div align="left">
<input type='fvalue' id='fvalue' name='fvalue' value='' onkeyup='fire()' size="10" />
</div></td>
</tr>
<tr>
<td bgcolor="#EBF0F9"><div align="right"><strong>: </strong></div></td>
<td bgcolor="#EBF0F9"><div align="left">
<input type='u_phone' id='u_phone' name='u_phone' value='' onKeyUp="calcBill()" size="10" />
</div></td>
<td bgcolor="#EBF0F9"><div align="right"><strong>¤èÒ¹éÓ/˹èÇ </strong>:</div></td>
<td bgcolor="#EBF0F9"><div align="left">
<input type='unit_water' id='u_water' name='u_water' value='' onKeyUp="calcBill()" size="10" />
</div></td>
<td bgcolor="#EBF0F9"><div align="right"><strong>¤èÒä¿</strong><strong>/˹èÇ :</strong></div></td>
<td bgcolor="#EBF0F9"><input type='u_fire' id='u_fire' name='u_fire' value='' onKeyUp="calcBill()" size="10" /></td>
</tr>
<tr>
<td bgcolor="#EBF0F9"><div align="right"><strong>ÃÇÁ </strong><strong>:</strong></div></td>
<td bgcolor="#EBF0F9"><div align="left">
<input type="text" id="total_phone" name="total_phone" value="<?php echo $value_room;?>" onKeyUp="total()" size="10"/>
</div></td>
<td bgcolor="#EBF0F9"><div align="right"><strong>ÃÇÁ : </strong></div></td>
<td bgcolor="#EBF0F9"><input type='total_water' id='total_water' name='total_water' value="0" onkeyup="calcBill()" size="10"/></td>
<td bgcolor="#EBF0F9"><div align="right"><strong>ÃÇÁ:</strong></div></td>
<td bgcolor="#EBF0F9"><div align="left">
<input type='total_fire' id='total_fire' name='total_fire' value="0" onkeyup="calcBill()" size="10"/>
</div></td>
</tr>
<tr>
<td bgcolor="#EBF0F9"> </td>
<td bgcolor="#EBF0F9"> </td>
<td bgcolor="#EBF0F9"> </td>
<td bgcolor="#EBF0F9"> </td>
<td bgcolor="#EBF0F9"> </td>
<td bgcolor="#EBF0F9"> </td>
</tr>
<tr>
<td colspan="6" bgcolor="#1E3C7B"><div align="center"> <span class="style14">ÃÇÁ : </span>
<input type='be_total' id='be_total' name='be_total' size="10"/>
<span class="style14"> ºÒ·</span></div></td>
</tr>
</table></td>
</tr>
</table>
<p align="center"></p>
<p align="center">
<? ?>
</p>
<p align="center"> </p>
<p> </p>
</form>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-10-26 06:09:39 |
By :
aung |
View :
814 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เมาโค๊ดอ่ะพี่น้อง
|
|
|
|
|
Date :
2009-10-28 07:35:08 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยาวจังครับ เด๋วลองดูก่อนนะครับ ได้หรือ งง ยังไง จะมาบอกอีกทีครับ
|
|
|
|
|
Date :
2009-10-28 09:30:09 |
By :
tingtongkub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|