echo "<table border='1' style='border-collapse:collapse;' width='97%' align='center'>"; echo "<tr height='50' style='font-size:25px;'>"; echo "<th width='30%'>สินค้า</th>"; echo "<th width='10%'>ต้นงวด</th>"; echo "<th width='10%'>ในงวด</th>"; echo "<th width='10%'>ยอดตรวจนับ</th>"; echo "<th width='10%'>ผลลัพธ์</th>"; echo "</tr>"; $product = productAll(); $numrow =mysqli_num_rows($product); for($i=1;$i<=$numrow;$i++) { $pd=mysqli_fetch_array($product); echo "<tr height='50' style='font-size:25px;'>"; echo "<td>product$i</td>"; echo "<td align='center'><input type='textbox' name='begin[$i]' value='' size='12' style='text-align:right' maxlength='12' style='height:30' autocomplete='off' OnKeyPress='return chkNumber(this)'></td>"; echo "<td align='center'><input type='textbox' name='buy[$i]' value='' size='12' style='text-align:right' maxlength='12' style='height:30' autocomplete='off' OnKeyPress='return chkNumber(this)'></td>"; echo "<td align='center'><input type='textbox' name='count[$i]' value='' size='12' style='text-align:right' maxlength='12' style='height:30' autocomplete='off' OnKeyPress='return chkNumber(this)'></td>"; echo "<td align='center'><input type='textbox' name='rabuy[$i]' value='' size='12' style='text-align:right' maxlength='12' style='height:30' readonly='true' autocomplete='off' OnKeyPress='return chkNumber(this)' ></td>"; echo "</tr>"; } echo "</table>";
<!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" /> <link rel="stylesheet" type="text/css" href="../colorbox-master/colorbox.css" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> <script type="text/javascript" src="../colorbox-master/jquery.colorbox-min.js"></script> <script type="text/javascript"> $(function(){ $("#calbtn").click(function(){ var obj = $("table").eq(0); var row = obj.find("tr"); for(i=0;i<row.length;i++){ var txt = row.eq(i).find("input"); if(txt.length>0){ var c1 = txt.eq(0).val(); var c2 = txt.eq(1).val(); var c3 = txt.eq(2).val(); var c4 = parseFloat(c1)+parseFloat(c2)-parseFloat(c3) txt.eq(3).val(c4); } } }); }); </script> </head> <body> <?php echo "<table border='1' style='border-collapse:collapse;' width='97%' align='center'>"; echo "<tr height='50' style='font-size:25px;'>"; echo "<th width='30%'>สินค้า</th>"; echo "<th width='10%'>ต้นงวด</th>"; echo "<th width='10%'>ในงวด</th>"; echo "<th width='10%'>ยอดตรวจนับ</th>"; echo "<th width='10%'>ผลลัพธ์</th>"; echo "</tr>"; for($i=1;$i<=10;$i++) { echo "<tr height='50' style='font-size:25px;'>"; echo "<td>product$i</td>"; echo "<td align='center'><input type='textbox' name='begin[$i]' value='".rand(0,500)."' size='12' style='text-align:right' maxlength='12' style='height:30' autocomplete='off' OnKeyPress='return chkNumber(this)'></td>"; echo "<td align='center'><input type='textbox' name='buy[$i]' value='".rand(0,500)."' size='12' style='text-align:right' maxlength='12' style='height:30' autocomplete='off' OnKeyPress='return chkNumber(this)'></td>"; echo "<td align='center'><input type='textbox' name='count[$i]' value='".rand(0,500)."' size='12' style='text-align:right' maxlength='12' style='height:30' autocomplete='off' OnKeyPress='return chkNumber(this)'></td>"; echo "<td align='center'><input type='textbox' name='rabuy[$i]' value='' size='12' style='text-align:right' maxlength='12' style='height:30' readonly='true' autocomplete='off' OnKeyPress='return chkNumber(this)' ></td>"; echo "</tr>"; } echo "</table>"; ?> <input type="button" value="calculate" id="calbtn" /> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง