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