By GokiSoft.com| 14:02 19/10/2020|
Học JS

[Share Code] Bài tập - ôn tập mảng - quản lý sinh viên - Lập trình Javascript

#BT2008.html


<!DOCTYPE html>
<html>
<head>
	<title>Quan Ly Sinh Vien</title>
</head>
<body>
	<table border="1" cellspacing="3" cellpadding="3">
		<thead>
			<tr>
				<th colspan="6">Quan Ly Sinh Vien</th>
			</tr>
			<tr>
				<th>STT</th>
				<th>Ten</th>
				<th>Tuoi</th>
				<th>Email</th>
				<th>SDT</th>
				<th>Dia Chi</th>
			</tr>
		</thead>
		<tbody>
<script type="text/javascript">
	var studentList = []

	//Sinh ra 20 doi tuong sinh vien
	for (var i = 0; i < 20; i++) {
		std = {
			'fullname': 'A ' + i,
			'age': i,
			'address': 'HN ' + i,
			'email': 'a'+i+'@gmail.com',
			'phone_number': '123' + i
		};
		studentList.push(std)
	}

	//Hien thi
	for (var i = 0; i < studentList.length; i++) {
		document.writeln(`<tr>
					<td>${i + 1}</td>
					<td>${studentList[i].fullname}</td>
					<td>${studentList[i].age}</td>
					<td>${studentList[i].address}</td>
					<td>${studentList[i].email}</td>
					<td>${studentList[i].phone_number}</td>
				</tr>`)
		// document.writeln('<tr>'+
		// 			'<td>'+(i + 1)+'</td>'+
		// 			'<td>'+(studentList[i].fullname)+'</td>'+
		// 			'<td>'+(studentList[i].age)+'</td>'+
		// 			'<td>'+(studentList[i].address)+'</td>'+
		// 			'<td>'+(studentList[i].email)+'</td>'+
		// 			'<td>'+(studentList[i].phone_number)+'</td>'+
		// 		'</tr>')
	}
</script>
		</tbody>
	</table>
</body>
</html>


Tags:

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)