By GokiSoft.com|
20:13 25/10/2023|
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 - C2307L
Bài tập - ôn tập mảng - quản lý sinh viên - Lập trình Javascript
<!DOCTYPE html>
<html>
<head>
<title>Quản lý sinh viên - Lập trình Javascript</title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var stdList = []
//Tạo ngẫu nhiên 20 sinh viên
for (var i = 0; i < 20; i++) {
stdList.push({
'fullname': 'TRAN VAN ' + i,
'age': i,
'address': 'Ha Noi',
'email': i + "@gmail.com",
'phone': '12345678' + i
})
}
//Hiển thị kết quả ra 1 table như sau
</script>
<table border="1" cellpadding="0" cellspacing="0" style="width: 100%">
<thead>
<tr>
<th>STT</th>
<th>Ten</th>
<th>Tuoi</th>
<th>Dia Chi</th>
<th>Email</th>
<th>SDT</th>
</tr>
</thead>
<tbody>
<script type="text/javascript">
for (var i = 0; i < stdList.length; i++) {
document.write(`<tr>
<td>${i+1}</td>
<td>${stdList[i].fullname}</td>
<td>${stdList[i].age}</td>
<td>${stdList[i].address}</td>
<td>${stdList[i].email}</td>
<td>${stdList[i].phone}</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)