<html> <head> <script language="javascript"> function calc(box){ one = document.autoSumForm.firstBox.value; two = document.autoSumForm.secondBox.value; third = document.autoSumForm.thirdBox.value; if(box == 1){ document.autoSumForm.thirdBox.value = (one * 1) + ((two / 100) * one); } } </script> </head> <body> <div style="width: 200px; text-align: center;"> <form name="autoSumForm" method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Keyword <input name="txtKeyword" type="text" id="txtKeyword" value="<?php echo $_GET["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <?php if($_GET["txtKeyword"] != "") { $objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database"); $objDB = mysql_select_db("sompopv"); $strSQL = "SELECT * FROM aaa WHERE (b1 LIKE '%".$_GET["txtKeyword"]."%' )"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table width="600" border="1"> <tr> <th width="91"> <div align="center">b1 </div></th> <th width="98"> <div align="center">b2 </div></th> <th width="198"> <div align="center">b3 </div></th> </tr> <?php while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"> <input type="text" name="b1" value="<?php echo $objResult["b1"];?>"> </form> </div></td> <td> <input type="text" name="b2" value="<?php echo $objResult["b2"];?>"></td> <td> <input type="text" name="b3" value="<?php echo $objResult["b3"];?>"></td> </tr> <?php } ?> </table> <?php mysql_close($objConnect); } ?> </body> </html>
<table> <tr> <td><input type="number" id="a1" rel='1' value="1"></td> <td><input type="number" id="b1" rel='1' value="2"></td> <td><input type="text" id="total_1" value="3" disabled></td> </tr> <tr> <td><input type="number" id="a2" rel='2' value="10"></td> <td><input type="number" id="b2" rel='2' value="20"></td> <td><input type="text" id="total_2" value="30" disabled></td> </tr> </table> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $(function(){ $('input[type=number]').on('keyup',function(){ total($(this).attr('rel')); }); }); function total(rel){ var total=0; total=parseInt($('#a'+rel).val())+parseInt($('#b'+rel).val()); // condition $('#total_'+rel).val(total); } </script>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง