Selamat sore agan2, mohon pencerahannya.
Saya membuat membuat perhitungan rata2 pada tabel array, pada row pertama berhasil menghitung namun pada row berikutnya gagal. mohon bantuannya, terima kasih agan2...

https://img1.uploadhouse.com/fileuploads/26092/260925516e556090107abe660965bdcf9160283e.jpg

  1. <script language="javascript" >
  2. function OperasiPerhitungan(){
  3. A1 = document.getElementById("angka1").value;
  4. A2 = document.getElementById("angka2").value;
  5. A3 = (parseFloat(A1) + parseFloat(A2))/2;
  6. document.getElementById("hasil").value =A3;
  7. }
  8. </script>
  9. <div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
  10. <div class="row">
  11. <div class="col-lg-12">
  12. <center><h3 class="page-header">EDIT NILAI</h3></center>
  13. </div>
  14. </div><!--/.row-->
  15. <?php include ('koneksi.php');
  16. $nip=$_SESSION['$nip'];
  17. ?>
  18. <div class="row">
  19. <div class="col-lg-12">
  20. <div class="panel panel-danger">
  21. <div class="panel-body">
  22. <form method="POST" action="input_nilai_edit_proses.php">
  23. <table id="example" class="" cellspacing="0" width="100%">
  24. <thead>
  25. <tr class="alert warning">
  26. <th>No</th>
  27. <th></th>
  28. <th>NIS</th>
  29. <th>Siswa</th>
  30. <th>UH 1</th>
  31. <th>UH 2</th>
  32. <th>RERATA</th>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. <?php
  37. include('koneksi.php');
  38. $id_mapel = $_GET['id_mapel'];
  39. $query = mysql_query("SELECT siswa.nama,nilai.id_mapel, nilai.id_nilai,
  40. nilai.nis, nilai.uh1,nilai.uh2
  41. FROM siswa, nilai WHERE siswa.nis=nilai.nis AND nilai.id_mapel= '$id_mapel'");
  42. $no = 0; //membuat variabel $no untuk membuat nomor urut
  43. while($data = mysql_fetch_array($query)){
  44. $no++;
  45. $id_nilai = $data['id_nilai'];
  46. $id_mapel = $data['id_mapel'];
  47. $rerata = $data['rerata'];
  48. ?>
  49. <tr>
  50. <td><?php echo $no; ?></td>
  51. <td><input type="hidden" name="id_nilai[]" value="<?php echo $data['id_nilai']; ?>"></td>
  52. <td><?php echo $data['nis']; ?></td>
  53. <td><?php echo $data['nama']; ?></td>
  54. <td><input type="number" name="uh1[]" id="angka1" onchange="OperasiPerhitungan();" value="0" style="width:50px"></td>
  55. <td><input type="number" name="uh2[]" id="angka2" onchange="OperasiPerhitungan();" value="0" style="width:50px"></td>
  56. <td><input type="number" name="rerata[]" id="hasil" disabled="disabled" value="0" style="width:80px"></td>
  57. </tr>
  58. <?php } ?>
  59. </tbody>
  60. </table>
  61. <div class='navbar-form pull-left'>
  62. <button type="submit" name="tambah" class="btn btn-danger">Simpan</button>
  63. </div>
  64. </form>
15210
Please login to answer!
/sangkep/answer/add-json/nogzip/1
/sangkep/answer/send-notification
User Paling Aktif Bulan Lalu

iswandi

Point Bulan Lalu: 6