PHP Ionic Angularjs Phonegap AJAX Javascript CSS MySQL jQuery Forum

ช่วยหน่อยครับ java and php ปัดเศษครับ เช่น 1.4*3= 4.19999999 =4.2

ช่วยหน่อยครับ java and php ปัดเศษครับ เช่น 1.4*3= 4.19999999 =4.2
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
	background-image: url(image/3.jpg);
}
</style>
</head>
</style>
<script language="javascript">
function fnccheck(){
	var num1=document.getElementById('num1').value;
	var x1=document.getElementById('x1').value;
    
	var num2=document.getElementById('num2').value; 
	var x2=document.getElementById('x2').value; 
	
    var num3=document.getElementById('num3').value;
	var x3=document.getElementById('x3').value; 
	 
	var num4=document.getElementById('num4').value; 
	var x4=document.getElementById('x4').value; 
	
	var num5=document.getElementById('num5').value;
	var x5=document.getElementById('x5').value;
	 
	var num6=document.getElementById('num6').value;
	var x6=document.getElementById('x6').value;
	 
	var num7=document.getElementById('num7').value;
	var x7=document.getElementById('x7').value; 
	 
	var num8=document.getElementById('num8').value;
	var x8=document.getElementById('x8').value;
	 
	var num9=document.getElementById('num9').value; 
	var x9=document.getElementById('x9').value; 
	
	var num10=document.getElementById('num10').value; 
	var x10=document.getElementById('x10').value; 
	
	var num11=document.getElementById('num11').value;
	var x11=document.getElementById('x11').value;
	  
	var num12=document.getElementById('num12').value;
	var x12=document.getElementById('x12').value; 
	 
	var num13=document.getElementById('num13').value; 
	var x13=document.getElementById('x13').value; 
	
	var num14=document.getElementById('num14').value; 
	var x14=document.getElementById('x14').value; 
	
	var glass=document.getElementById('glass').value; 
	var x15=document.getElementById('x15').value; 

    
	 //var num15=document.getElementById('num15'); 
	//var num16=document.getElementById('num16');
	//var num17=document.getElementById('num17');
	//var num18=document.getElementById('num18');
	//var num19=document.getElementById('num19');
	//var num20=document.getElementById('num20');
	//var num21=document.getElementById('num21');
	//var num22=document.getElementById('num22');
	//var num23=document.getElementById('num23');
	//var num24=document.getElementById('num24');
	//var num25=document.getElementById('num25');
	//var num26=document.getElementById('num26');
	//var num27=document.getElementById('num27');
	//var num28=document.getElementById('num28');
	//var num29=document.getElementById('num29');
	var sum=document.getElementById('sum');
	
if(num1 == ""){num1 = 0;}
if(x1 == ""){x1 = 0;}
if(num2 == ""){num2 = 0;}
if(x2 == ""){x2 = 0;}
if(num3 == ""){num3 = 0;}
if(x3 == ""){x3 = 0;}
if(num4 == ""){num4 = 0;}
if(x4 == ""){x4 = 0;}
if(num5 == ""){num5 = 0;}
if(x5 == ""){x5 = 0;}
if(num6 == ""){num6 = 0;}
if(x6 == ""){x6 = 0;}
if(num7 == ""){num7 = 0;}
if(x7 == ""){x7 = 0;}
if(num8 == ""){num8 = 0;}
if(x8 == ""){x8 = 0;}
if(num9 == ""){num9 = 0;}
if(x9 == ""){x9 = 0;}
if(num10 == ""){num10 = 0;}
if(x10 == ""){x10 = 0;}
if(num11 == ""){num11 = 0;}
if(x11 == ""){x11 = 0;}
if(num12 == ""){num12 = 0;}
if(x12 == ""){x12 = 0;}
if(num13 == ""){num13 = 0;}
if(x13 == ""){x13 = 0;}
if(num14 == ""){num14 = 0;}
if(x14 == ""){x14 = 0;}
if(glass == ""){glass = 0;}
if(x15 == ""){x15 = 0;} 

 num15.value=parseFloat(num1)*parseFloat(x1);
 num16.value=parseFloat(num2)*parseFloat(x2);
 num17.value=parseFloat(num3)*parseFloat(x3);
 num18.value=parseFloat(num4)*parseFloat(x4);
 num19.value=parseFloat(num5)*parseFloat(x5);
 num20.value=parseFloat(num6)*parseFloat(x6);
 num21.value=parseFloat(num7)*parseFloat(x7);
 num22.value=parseFloat(num8)*parseFloat(x8);
 num23.value=parseFloat(num9)*parseFloat(x9);
 num24.value=parseFloat(num10)*parseFloat(x10);
 num25.value=parseFloat(num11)*parseFloat(x11);
 num26.value=parseFloat(num12)*parseFloat(x12);
 num27.value=parseFloat(num13)*parseFloat(x13);
 num28.value=parseFloat(num14)*parseFloat(x14);
 num29.value=parseFloat(glass)*parseFloat(x15);
 
 
  sum.value =Math.round(num15.value)+Math.round(num16.value)+Math.round(num17.value)+Math.round(num18.value)+Math.round(num19.value)+Math.round(num20.value)+Math.round(num21.value)+Math.round(num22.value)+Math.round(num23.value)+Math.round(num24.value)+Math.round(num25.value)+Math.round(num26.value)+Math.round(num27.value)+Math.round(num28.value)+Math.round(num29.value);
}
</script>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <table width="650" height="986" border="1" align="center">
    <tr valign="baseline">
      <td colspan="3" align="center" nowrap="nowrap" bgcolor="#00CC33"><strong>เพิ่มข้อมูลลงในลงในตาราง</strong></td>
    </tr>
    <tr valign="baseline">
      <td rowspan="3" align="right" nowrap="nowrap" bgcolor="#00FF00">&nbsp;</td>
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">เลขที่บัญชี:</td>
      <td bgcolor="#CCCCCC"><input type="text" name="id" value="" size="20" /></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">วัน/เดือน/ปี:</td>
      <td bgcolor="#CCCCCC"><input type="text" name="date" value="" size="20" /></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">ชื่อ-สกุล:</td>
      <td bgcolor="#CCCCCC"><input type="text" name="name_last" value="" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td rowspan="8" align="right" valign="middle" nowrap="nowrap" bgcolor="#00FF00"><input type="" name="plas" value="พลาสติก" size="10" /></td>
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><label for="select"></label>
        <select name="list1" id="select">
          <option>ใส</option>
        </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.:</td>
      <td bgcolor="#CCCCCC"><input name="num1" id="num1"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
      *
        <input name="x1" type="text" id="x1" onchange="JavaScript:return fnccheck();" value="" size="10" />      
        =
      <input name="num15" type="text" id="num15" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><label for="select"></label>
        <select name="list2" id="select">
          <option>ขาวขุ่น</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.:</td>
      <td bgcolor="#CCCCCC"><input name="num2" id="num2"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x2" type="text" id="x2" size="10" value="" Onchange="JavaScript:return fnccheck();"/>      =
      <input name="num16" type="text" id="num16" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><label for="select"></label>
        <select name="list3" id="select">
          <option>กรอบ</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.:</td>
      <td bgcolor="#CCCCCC"><input name="num3" id="num3"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x3" type="text" id="x3" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num17" type="text" id="num17" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><label for="select"></label>
        <select name="list4" id="select">
          <option>รวม</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.:</td>
      <td bgcolor="#CCCCCC"><input name="num4" id="num4"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x4" type="text" id="x4" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num18" type="text" id="num18" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td rowspan="12" align="right" valign="middle" nowrap="nowrap" bgcolor="#00FF00"><input name="loha" value="โลหะ" size="10" /></td>
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="l1" id="select2">
          <option>เหล็ก</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num5" id="num5"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x5" type="text" id="x5" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num19" type="text" id="num19" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="l2" id="select2">
         <option>โลหะ</option
      ></select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num6" id="num6"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x6" type="text" id="x6" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num20" type="text" id="num20" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="l3" id="select2">
         <option>อลูมิเนียม</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num7" id="num7"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x7" type="text" id="x7" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num21" type="text" id="num21" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="l4" id="select2">
         <option>ทองเหลือง</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num8" id="num8"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x8" type="text" id="x8" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num22" type="text" id="num22" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="l5" id="select2">
        <option>ทองแดง</option>
         </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num9" id="num9"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x9" type="text" id="x9" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num23" type="text" id="num23" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="l6" id="select2">
          <option>สังกะสี</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num10" id="num10"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x10" type="text" id="x10" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num24" type="text" id="num24" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td rowspan="8" align="right" valign="middle" nowrap="nowrap" bgcolor="#00FF00">
      <input type="text" name="paper" value="กระดาษ" size="10" /></td>
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="s1" id="select3">
          <option>ขาว-ดำ</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num11" id="num11"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x11" type="text" id="x11" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num25" type="text" id="num25" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="s2" id="select3">
          <option>ลัง</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num12" id="num12"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x12" type="text" id="x12" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num26" type="text" id="num26" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="s3" id="select">
      <option>รวม</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num13" id="num13"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x13" type="text" id="x13" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num27" type="text" id="num27" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><select name="s4" id="select">
          <option>หนังสือพิมพ์</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">กก.</td>
      <td bgcolor="#CCCCCC"><input name="num14" id="num14"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x14" type="text" id="x14" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      =
      <input name="num28" type="text" id="num28" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td rowspan="3" align="right" nowrap="nowrap" bgcolor="#00FF00">&nbsp;</td>
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">ขวดแก้ว/กก:</td>
      <td bgcolor="#CCCCCC"><input name="glass" id="glass"  type="text" value="" size="10" Onchange="JavaScript:return fnccheck();"/>
        *
      <input name="x15" type="text" id="x15" size="10" value="" Onchange="JavaScript:return fnccheck();" />
      =
      <input name="num29" type="text" id="num29" size="10" value="" Onchange="JavaScript:return fnccheck();"/>
      บาท</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap" bgcolor="#00FF66">รวม/จำนวนเงิน</td>
      <td bgcolor="#CCCCCC"><input name="sum" id="sum"  type="text" value="" size="20" /></td>
    </tr>
    <tr valign="baseline">
      <td height="28" align="right" nowrap="nowrap" bgcolor="#00FF66">&nbsp;</td>
      <td bgcolor="#CCCCCC"><input type="submit" value="เพิ่มข้อมูล" />
      <input type="reset" name="Reset" id="button" value="Reset" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<center>
<p><a href="http://localhost/bankrecycledb/admin/foradmin.php"><img src="image/home.gif" width="29" height="31" /></a></p>
</p></center>
</body>
</html>


โดย:  Soomsam77 IP: 122.154.245.xxx วันที่: 17-03-2015 เวลา: 09:45:39

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ


  • ( หรือ สามารถทำการ สมัครสมาชิก และล็อกอิน ด้วย ปุ่ม Log in with Facebook ด้านล่าง )
 ความคิดเห็นที่ 2
ขอบพระคุณอย่างมากครับ ขอให้พระเจ้าอวยพรท่านครับ

โดย:  Soomsam77 IP: 122.154.245.xxx วันที่: 17-03-2015 เวลา: 10:37:29
 ความคิดเห็นที่ 1
ถ้าหมายถึง javascript ดูนี่เป็นแนวทาง

การจัดรูปแบบทศนิยมของตัวเลขใน javascript 
http://www.ninenik.com/content.php?arti_id=82 via @ninenik

ส่วน php ของดู ฟังก์ชั่น round()

http://php.net/manual/en/function.round.php


โดย:  Ninenik IP: 171.96.6.xxx วันที่: 17-03-2015