Bagaimana menghitung sum dari semua total

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style>
		.container{
			font-size: 15px;
			color: #343d44;
			font-family: "segoe-ui", "open-sans", tahoma, arial;
			padding: 10px;
			background: grey;
			margin: left;
		}

		h2{
			text-align: center;
			text-decoration: underline;

		}

		table{
			margin: auto;
			font-family: "Lucida Sans Unicode", "Lucida Grande", "Segoe Ui";
			background: white;
			font-size: 12px;
			width : 500px;
			text-align: justify;
		}
		td{
			padding: 50px
		}
	</style>
</head>
<body>
	<div class="container">
		<h2>AI1</h2>
		<h2>Level 0</h2>
		<table border="1">
			<tr>
				<th>No</th>
				<th>Statement</th>
				<th>jumlah</th>
			</tr>

			<tr>
				<th>1</th>
				<th>The organisation does not require the identification of functional and operational requirements for development, implementation or modification of solutions, such as system, service, infrastructure, software and data.</th>
				<th><input type="text" name="non" id="level0" size="7" value="0" onchange="total()"></th>
			</tr>

			<tr>
				<th>2</th>
				<th>The organisation does not maintain an awareness of available technology solutions potentially relevant to its business.</th>
				<th><input type="text" name="non1" id="level0_1" size="7" value="0" onchange="total()"></th>
			</tr>

			<tr>

				<th colspan="2" style="text-align:right">Total</th>
				<th><input type="text" name="total_jumlah" id="total" size="7" value="0" readonly></th>
			</tr>
		</table>

		<script type="text/javascript">
		function total() {
		var a = parseInt(document.getElementById('level0').value);
		var b = parseInt(document.getElementById('level0_1').value);
		var sum = (a+b)/2;

		document.getElementById('total').value = sum;
		}

		</script>
	</div>
	<div class="container">
		<h2>AI1</h2>
		<h2>Level 1</h2>
		<table border="1">
			<tr>
				<th>No</th>
				<th>Statement</th>
				<th>jumlah</th>
			</tr>

			<tr>
				<th>1</th>
				<th>There is an awareness of the need to define requirements and identify technology solutions.</th>
				<th><input type="text" name="initial" id="level1" size="7" value="0" onchange="total1()"></th>
			</tr>

			<tr>
				<th>2</th>
				<th>Individual groups meet to discuss needs informally, and requirements are sometimes documented.</th>
				<th><input type="text" name="initial1" id="level1_1" size="7" value="0" onchange="total1()"></th>
			</tr>

			<tr>
				<th>3</th>
				<th>Solutions are identified by individuals based on limited market awareness or in response to vendor offerings.</th>
				<th><input type="text" name="initial2" id="level1_2" size="7" value="0" onchange="total1()"></th>
			</tr>

			<tr>
				<th>4</th>
				<th>There is minimal structured research or analysis of available technology.</th>
				<th><input type="text" name="initial3" id="level1_3" size="7" value="0" onchange="total1()"></th>
			</tr>

			<tr>

				<th colspan="2" style="text-align:right">Total</th>
				<th><input type="text" name="total_jumlah1" id="total1" size="7" value="" readonly></th>
			</tr>
		</table>

		<script type="text/javascript">
		function total1() {
		var c = parseInt(document.getElementById('level1').value);
		var d = parseInt(document.getElementById('level1_1').value);
		var e = parseInt(document.getElementById('level1_2').value);
		var f = parseInt(document.getElementById('level1_3').value);
		var sum1 = (c+d+e+f)/4;

		document.getElementById('total1').value = sum1;
		}

		</script>
	</div>

	<div class="container">
		<table border="1">
		<tr>
		<th colspan="2" style="text-align:right">SUM</th>
		<th><input type="text" name="subtotal" id="u" size="7" value="0" onchange="total10()"></th>
		</tr>

</body>
<br><br>
		<input type="button" onclick="window.print()" value="cetak">
</html>

avatar Ufuaida
@Ufuaida

1 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

Tanggapan

jelaskan masalahnya, errornya dan lain-lain

1 Jawaban:

buat 1 fungsi lagi yg menjumlahkan nilai dari input ber-id total dan total1 kemudian panggil fungsi tersebut di fungsi total() dan total1()

cmiiw

avatar anandap7
@anandap7

7 Kontribusi 6 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban