Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > จวนจะได้แล้ว type="text" onkeyup="calcBill()" มันหมายความว่ายังไง ช่วยทำให้หน่อยนะค่ะ



 

จวนจะได้แล้ว type="text" onkeyup="calcBill()" มันหมายความว่ายังไง ช่วยทำให้หน่อยนะค่ะ

 



Topic : 033415

Guest




คือมีคน ให้ code มา แล้วบอกให้เปลี่ยนตรง input
type="text" onkeyup="calcBill()" มันหมายความว่ายังไง ช่วยทำให้หน่อยนะค่ะ


Code (PHP)
<!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">
<script language='javascript' 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>
<head>
<style type="text/css">
<!--
.style14 {color: #FFFFFF}
.style15 {   color: #FFFFFF;
   font-weight: bold;
}
-->
</style>

<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link href="css/new.css" rel="stylesheet" type="text/css">
<title>ระบบบริหารงานห้องเช่า</title>



           <script language='javascript' type='text/javascript'>
function water(){
var water = document.form2.wvalue.value;
var se2 = document.form2.u_water.value;
if(water == "" || water == ""){return false;}
var total = 0;
total = Number(water) * Number(se2);
form2.total_water.value = addCommas(total.toFixed(2));
}
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;
}
</script>
          <script language='javascript' type='text/javascript'>
    function fire(){
   var fire = document.form2.fvalue.value;
   var se1 = document.form2.u_fire .value;
   if(fire == "" || fire == ""){return false;}
   var total = 0;
   total = Number(fire)  * Number(se1);
 form2.total_fire.value = addCommas(total.toFixed(2));
   }
  </script>
    <script language='javascript' type='text/javascript'>
    function phone1(){
   var p1 = document.form2.pvalue.value;
   var up = document.form2.u_phone .value;
   if(p1 == "" || p1 == ""){return false;}
   var total = 0;
   total = Number(p1)  * Number(up);
   form2.total_phone.value = addCommas(total.toFixed(2));
   }
  </script>
            <script language='javascript' type='text/javascript'>
    function total(){
   var phone = document.form2.total_phone.value;
   var fire = document.form2.total_fire .value;
    var wate = document.form2.total_water .value;
   if(phone == "" || phone == ""){return false;}
   var total = 0;
   total = Number(phone)  + Number(fire)+ Number(wate);
   form2.be_total.value = addCommas(total.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="form2" name="form2" method="post" action="unitinsert.php">
        <p>&nbsp;</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='phone1()' 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='water()' 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='fire()' 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='total_phone' id='total_phone' name='total_phone' value="0" 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   ='total()' 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   ='total()' size="10"/>
                    </div></td>
                  </tr>
                  <tr>
                    <td bgcolor="#EBF0F9">&nbsp;</td>
                    <td bgcolor="#EBF0F9">&nbsp;</td>
                    <td bgcolor="#EBF0F9">&nbsp;</td>
                    <td bgcolor="#EBF0F9">&nbsp;</td>
                    <td bgcolor="#EBF0F9">&nbsp;</td>
                    <td bgcolor="#EBF0F9">&nbsp;</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">&nbsp;</p>
        <p align="center">&nbsp;</p>
            <p>&nbsp;</p>
      </form>
    </td>
  </tr>
</table>
</body>
</html>




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-10-23 08:02:31 By : aung View : 887 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ONKeyUp เมื่อมีการกดปุ่มแล้วปล่อยปุ่มขึ้นน่ะครับ






Date : 2009-10-23 08:39:48 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : จวนจะได้แล้ว type="text" onkeyup="calcBill()" มันหมายความว่ายังไง ช่วยทำให้หน่อยนะค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่