<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <SCRIPT Language="JavaScript"> function startCalc(row){ interval = setInterval("calc('"+row+"')",1); } function calc(row){ var txttarget = document.forms['autoSumForm'].elements['target[]']; var txtsumassess = document.forms['autoSumForm'].elements['sumassess[]']; var txtgap = document.forms['autoSumForm'].elements['gap[]']; var txttotalgap = document.forms['autoSumForm'].elements['totalgap']; var lentxt = txtgap.length; /* var txttarget = document.forms['autoSumForm'].elements['target']; var txtsumassess = document.forms['autoSumForm'].elements['sumassess']; var txtgap = document.forms['autoSumForm'].elements['gap'];*/ /* one = document.autoSumForm.target.value; two = document.autoSumForm.sumassess.value; */ var result = (txtsumassess[row].value * 1) - (txttarget[row].value * 1); txtgap[row].value =result ; var total = 0; for(var i=0; i < lentxt; i++) { total = total + (txtgap[i].value*1); } txttotalgap.value =total ; } function stopCalc(){ clearInterval(interval); } </SCRIPT> <div style="width: 200px; text-align: center;"> <form name="autoSumForm"> <table width="685" border="0"> <tr> <td><div align="left">target</div></td> <td><div align="left"> sumassess</div></td> <td><div align="left"> GAP</div></td> </tr> <tr> <td width="144"> <div align="left"> <input class="right" type=text name="target[]" value="" onFocus="startCalc('0');" onBlur="stopCalc();"> </div></td> <td width="159"><div align="left">- <input class="right" type=text name="sumassess[]" value="" onFocus="startCalc('0');" onBlur="stopCalc();"> </div></td> <td width="368"><div align="left">= <input class="right" type=text name="gap[]"> </div></td> </tr> <tr> <td width="144"> <div align="left"> <input class="right" type=text name="target[]" value="" onFocus="startCalc('1');" onBlur="stopCalc();"> </div></td> <td width="159"><div align="left">- <input class="right" type=text name="sumassess[]" value="" onFocus="startCalc('1');" onBlur="stopCalc();"> </div></td> <td width="368"><div align="left">= <input class="right" type=text name="gap[]"> </div></td> </tr> <tr> <td width="144"> <div align="left"> <input class="right" type=text name="target[]" value="" onFocus="startCalc('2');" onBlur="stopCalc();"> </div></td> <td width="159"><div align="left">- <input class="right" type=text name="sumassess[]" value="" onFocus="startCalc('2');" onBlur="stopCalc();"> </div></td> <td width="368"><div align="left">= <input class="right" type=text name="gap[]"> </div></td> </tr> <tr> <td width="144"> <div align="left"> </div></td> <td width="159"><div align="left">Result </div></td> <td width="368"><div align="left">= <input class="right" type=text name="totalgap"> </div></td> </tr> </table> <p> </p> </form> </div> </BODY> </HTML>
for($i=0; $i<sizeof($_POST['gap']); $i++) { echo $_POST['gap'][$i]; }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <SCRIPT Language="JavaScript"> function startCalc(row){ interval = setInterval("calc('"+row+"')",1); } function calc(row){ var txttarget = document.forms['autoSumForm'].elements['target[]']; var txtsumassess = document.forms['autoSumForm'].elements['sumassess[]']; var txtgap = document.forms['autoSumForm'].elements['gap[]']; var txttotalgap = document.forms['autoSumForm'].elements['totalgap']; var lentxt = txtgap.length; /* var txttarget = document.forms['autoSumForm'].elements['target']; var txtsumassess = document.forms['autoSumForm'].elements['sumassess']; var txtgap = document.forms['autoSumForm'].elements['gap'];*/ /* one = document.autoSumForm.target.value; two = document.autoSumForm.sumassess.value; */ var result = (txtsumassess[row].value * 1) - (txttarget[row].value * 1); txtgap[row].value =result ; var total = 0; for(var i=0; i < lentxt; i++) { total = total + (txtgap[i].value*1); } txttotalgap.value =total ; } function stopCalc(){ clearInterval(interval); } </SCRIPT> <div style="width: 200px; text-align: center;"> <form name="autoSumForm" method="post" action="cal.php"> <table width="685" border="1"> <tr> <td><div align="left">target</div></td> <td><div align="left"> sumassess</div></td> <td><div align="left"> GAP</div></td> </tr> <tr> <td width="144"> <div align="left"> <input class="right" type="text" name="target[]" value="" onFocus="startCalc('0');" onBlur="stopCalc();"> </div> </td> <td width="159"> <div align="left">- <input class="right" type="text" name="sumassess[]" value="" onFocus="startCalc('0');" onBlur="stopCalc();"> </div> </td> <td width="368"> <div align="left">= <input class="right" type="text" name="gap[]"> </div> </td> </tr> <tr> <td width="144"> <div align="left"> <input class="right" type="text" name="target[]" value="" onFocus="startCalc('1');" onBlur="stopCalc();"> </div> </td> <td width="159"> <div align="left">- <input class="right" type="text" name="sumassess[]" value="" onFocus="startCalc('1');" onBlur="stopCalc();"> </div> </td> <td width="368"> <div align="left">= <input class="right" type="text" name="gap[]"> </div> </td> </tr> <tr> <td width="144"> <div align="left"> <input class="right" type="text" name="target[]" value="" onFocus="startCalc('2');" onBlur="stopCalc();"> </div> </td> <td width="159"> <div align="left">- <input class="right" type="text" name="sumassess[]" value="" onFocus="startCalc('2');" onBlur="stopCalc();"> </div> </td> <td width="368"> <div align="left">= <input class="right" type="text" name="gap[]"> </div> </td> </tr> <tr> <td colspan="2"><div align="right">Result</div></td> <td width="368"> <div align="left">= <input type="text" name="totalgap"> </div> </td> </tr> <tr> <td align="center" colspan="3"> <input type="submit" name="submit_btn" id="submit_btn" value="Submit" /> </td> </tr> </table><!-- end table --> <p> </p> </form><!-- end form --> </div> </BODY> </HTML>
<?php if(isset($_POST['submit_btn'])) { echo '<table border="1">'; echo '<tr>'; echo '<th>target</th>'; echo '<th>sumassess</th>'; echo '<th>GAP</th>'; echo '</tr>'; for($i=0;$i<sizeof($_POST['target']);$i++) { echo '<tr>'; echo '<td>'.$_POST['target'][$i].'</td>'; echo '<td>'.$_POST['sumassess'][$i].'</td>'; echo '<td>'.$_POST['gap'][$i].'</td>'; echo '</tr>'; } echo '<tr>'; echo '<td colspan="2"><div align="right">Result</div></td>'; echo '<td width="368"><div align="left">='.$_POST['totalgap'].'</div></td>'; echo '</tr>'; echo'</table>'; } ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง