<?php $query3="SELECT students.stdid,students.stdnamelao,students.stdsurnamelao,students.gender FROM students INNER JOIN tbclass ON students.classid=tbclass.classid INNER JOIN departments on students.deptid=departments.deptid INNER JOIN majors ON students.majorid=majors.majorid INNER JOIN taughtby on tbclass.classid=taughtby.classid WHERE tbclass.classid='$vl5' AND students.yearid='$vl4' and majors.majorid='$vl3' AND taughtby.tid='$session_id' AND taughtby.subid='$vl1' "; $result3=mysql_query($query3)or die(mysql_error()); $c=0; while ($rows3=mysql_fetch_array($result3)) { $Stid= $rows3['stdid']; $Stnamelao= $rows3['stdnamelao']; $Stsurlao= $rows3['stdsurnamelao']; $Gd= $rows3['gender']; ?> <tr class="odd gradeX"> <td><?php echo $Stid ;?></td> <input type="hidden" name="tid[]" value="<?php echo $Stid ;?>"/> <td><?php echo $Stnamelao; ?></td> <input type="hidden" name="stnlao[]" value="<?php echo $Stnamelao ;?>"/> <td><?php echo $Stsurlao; ?></td> <input type="hidden" name="stslao[]" value="<?php echo $Stsurlao ;?>"/> <td ><?php echo $Gd; ?></td> <input type="hidden" name="Gd[]" value="<?php echo $Gd ;?>"/> <td><input type="text" name="score" size="3" id="score_" onKeyUp="calculate()" onKeyPress="CheckNum()" maxlength="3" ></td> <td><input type="text" name="score2" size="3" id="score2_"onKeyUp="calculate()" onKeyPress="CheckNum()"maxlength="3" class="form-control " ></td> <td><input type="text" name="score3" size="3" id="score3_" onKeyUp="calculate()" onKeyPress="CheckNum()"maxlength="3" class="form-control "></td> <td><input type="text" name="scorefull" id="scorefull" maxlength="3" size="3" class="form-control "readonly /></td> <input name="scoure%" type="hidden" id="scoure4" readonly maxlength="3" class="form-control " /> <td><input class="form-control "readonly id="scoregrad" maxlength="3" type="text" name="scoregrad" size="3" disabled ></td> <script type='text/javascript'> function checkNumber(elm){ if(elm.value>50){ alert('can not input over 50'); elm.value=''; } } </script> <script language="javascript"> function CheckNum(){ if (event.keyCode < 48 || event.keyCode > 57){ event.returnValue = false; } } </script> <script language="javascript"> function calculate() { var scorefull_ = 0; var scoregrad = "-"; var scoure4_ = "-"; var score = parseInt(document.getElementById('score_').value); var score2 = parseInt(document.getElementById('score2_' ).value); var score3 = parseInt(document.getElementById('score3_').value); var table = document.getElementById('example'); var rowCount = table.rows.length; if ( isNaN(score) ) { score = 0; } if ( isNaN(score2) ) { score2 = 0; } if ( isNaN(score3) ) { score3 = 0; } scorefull_=score+score2+score3; if (scorefull_) { scoure4_ = (scorefull_ /100)*80; document.getElementById('scoure4').value = scoure4_; } if (scorefull_>=80) { document.getElementById('scoregrad').value = "A"; } else if (scorefull_>=75) { document.getElementById('scoregrad').value = "B+"; } else if (scorefull_>=70) { document.getElementById('scoregrad').value = "B"; } else if (scorefull_>=65) { document.getElementById('scoregrad').value = "C+"; } else if (scorefull_>=60) { document.getElementById('scoregrad').value = "C"; } else if (scorefull_>=55) { document.getElementById('scoregrad').value = "D+"; }else if (scorefull_>=50) { document.getElementById('scoregrad').value = "D"; } document.getElementById('scorefull').value = scorefull_; if(scorefull_>100) { alert('can not input over 100'); if (score > 0 ) { score5 = scorefull_ - 100; score6 = score- score5; document.getElementById('score_').value =score6; } else if ( score2 > 0) { score5 = scorefull_ - 100; score7 = score2- score5; document.getElementById('score2_').value =score7; } else if ( score3 > 0) { score5 = scorefull_ - 100; score8 = score3- score5; document.getElementById('score3_').value =score8; } document.getElementById('scorefull').value =100; } } </script>
<?php for($i=0;$i<5;$i++) { ?> <input type="number" rel="<?=$i;?>"> <input type="text" id="grade_<?=$i;?>" disabled> <br> <?php } ?> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(function() { $('input').on('keyup',function(){ var val=$(this).val(); var rel=$(this).attr('rel'); if(val >= 80){ $('#grade_'+rel).val('A'); }else if(val >= 70){ $('#grade_'+rel).val('B'); }else if(val >= 60){ $('#grade_'+rel).val('C'); }else if(val >= 50){ $('#grade_'+rel).val('D'); }else{ $('#grade_'+rel).val('F'); } }); }); </script>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง