-
Notifications
You must be signed in to change notification settings - Fork 0
/
22-总额案例,渲染表格.html
62 lines (55 loc) · 1.3 KB
/
22-总额案例,渲染表格.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
h3 {
text-align: center;
}
table,
th,
td {
border: 1px solid #000;
}
table {
border-collapse: collapse;
height: 80px;
width: 900px;
margin: 0 auto;
text-align: center;
}
th {
padding: 5px 30px;
}
</style>
</head>
<body>
<script>
let price = +prompt("请输入单价:") // 前面的加号可以将输入转换成数字
let num = +prompt("请输入数量:")
let address = prompt("请输入收货地址:")
let sum = price * num
document.write(`
<h3>订单确认</h3>
<table>
<tr>
<th>商品名称</th>
<th>商品价格</th>
<th>商品数量</th>
<th>总价</th>
<th>收货地址</th>
</tr>
<tr>
<td>小米青春版</td>
<td>${price}元</td>
<td>${num}</td>
<td>${sum}元</td>
<td>${address}</td>
</tr>
</table>
`)
</script>
</body>
</html>