<!doctype html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js" ></script> <link rel="stylesheet" type="text/css" href="/css/result-light.css"> <style type="text/css"> </style> <!-- TODO: Missing CoffeeScript 2 --> <script type="text/javascript"> $(window).load(function(){ $(document).ready(function(){ // This button will increment the value $('.qtyplus').click(function(e){ // Stop acting like a button e.preventDefault(); // Get the field name var fieldName = $(this).prev(); // Get its current value var currentVal = parseInt(fieldName.val()); // If is not undefined if (!isNaN(currentVal )&& currentVal < 50) { // Increment fieldName.val(currentVal + 1); } else { // Otherwise put a 0 there fieldName.val(50); } }); // This button will decrement the value till 0 $(".qtyminus").click(function(e) { // Stop acting like a button e.preventDefault(); // Get the field name var fieldName = $(this).next(); // Get its current value var currentVal = parseInt(fieldName.val()); // If it isn't undefined or its greater than 0 if (!isNaN(currentVal) && currentVal > 0) { // Decrement one fieldName.val(currentVal - 1); } else { // Otherwise put a 0 there fieldName.val(0); } }); }); }); </script> <script type="text/javascript"> function calculate(count) { var total = 0; var water = parseInt(document.getElementById('water_' + count).value); var power = parseInt(document.getElementById('power_' + count).value); if ( isNaN(water) ) { water = 0; } if ( isNaN(power) ) { power = 0; } total = water + power; document.getElementById('total_' + count).value = total; } </script> <title>Untitled 5</title> </head> <body> <?php for ( $i = 1; $i <= 10; $i ++ ) { ?> <form method="post" action=".." id="form<?php echo $i ?>" name="form<?php echo $i ?>"> ค่าน้ำ <input type="text" id="water_<?php echo $i ?>" onKeyPress="calculate(<?php echo $i ?>)" onChange="calculate(<?php echo $i ?>)" onkeyup="calculate(<?php echo $i ?>)" onBlur="calculate(<?php echo $i ?>)" value="10" /> ค่าไฟ <input type='button' value='-' class='qtyminus' field='quantity' /> <input type='text' class="text-center" style="background-color:white;width:45px;" name='quantity' value='0' id="power_<?php echo $i ?>"onKeyPress="calculate(<?php echo $i ?>)" onBlur="calculate(<?php echo $i ?>)" onChange="calculate(<?php echo $i ?>)" onkeyup="calculate(<?php echo $i ?>)" onClick="calculate(<?php echo $i ?>)" onKeyDown="calculate(<?php echo $i ?>)"/> <input type='button' value='+' class='qtyplus' field='quantity' /> รวม <input type="text" id="total_<?php echo $i ?>" /> </form> <?php } ?> </body> </html>
<!doctype html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script> <!-- TODO: Missing CoffeeScript 2 --> <script type="text/javascript"> function fkx(){ var allsum = 0; var allsum = document.getElementById("devil").value; if(isNaN(water)){allsum=0;alert("not number")} allsum = parseInt(total) + parseInt(total); Document.getElementById("devil").value = allsum; } function calculate(count) { var total = 0; var pz = 0; var many = 0; var pz = document.getElementById("pz" + count).value; var many = document.getElementById("quantity" + count).value; if(isNaN(pz)){pz=0;alert("not number")} if(isNaN(many)){many=0;alert("not number")} total = parseInt(pz) * parseInt(many); document.getElementById("total_" + count).value = total; } function plus(id){ document.getElementById("quantity" + id).value = parseInt(document.getElementById("quantity" + id).value)+1; calculate(id); } function minus(id){ document.getElementById("quantity" + id).value = parseInt(document.getElementById("quantity" + id).value)-1; calculate(id); } </script> <title>Untitled 5</title> </head> <body> <?php for ( $i = 1; $i <= 10; $i ++ ) { ?> ค่าน้ำ <input type="text" id="pz<?php echo $i ?>" onkeyup="calculate(<?php echo $i ?>)" value="10" /> ค่าไฟ <input type='button' id="w_<?php echo $i ?>" value='-' field='quantity' onclick="minus(<?php echo $i ?>)"/> <input type='text' style="background-color:white;width:45px;" name='quantity' value='0' onkeyup="calculate(<?php echo $i ?>)" id="quantity<?php echo $i ?>" /> <input type='button' id="p_<?php echo $i ?>" value='+' field='quantity' onclick="plus(<?php echo $i ?>)" /> รวม <input type="text" id="total_<?php echo $i ?>" value="0" /> </br> <?php } ?>รวมทั้งหมด<input type='text' id='devil' onSelect="fkx();" onClick="fkx();" /> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง