-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtry.html
107 lines (76 loc) · 2.97 KB
/
try.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="my-3 ">
<form id="myForm">
<div class="form-check">
<input class="form-check-input" type="radio" value="nat" name="cat" id="flexRadioDefault1">
<label class="form-check-label" for="flexRadioDefault1">
National
</label>
</div>
<div class="form-check">
<input class="form-check-input" value="inter" type="radio" name="cat" id="flexRadioDefault2"
checked>
<label class="form-check-label" for="flexRadioDefault2">
internationl
</label>
</div>
<div class="mb-3">
<label for="exampleFormControlInput1" class="form-label">Weight(grams)</label>
<input type="number" name="weight" class="form-control" id="exampleFormControlInput1"
placeholder="in grams">
</div>
<span onclick="formSubmit()" class=" btn btn-warning">
submit
</span>
</form>
<div class="text-center">
<span id="price">
Your price
</span>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
function formSubmit() {
let form = document.getElementById("myForm");
let price = document.getElementById("price");
let category = form.cat.value;
let weight = form.weight.value;
let displayPrice = 0;
if (category == "nat") {
if (weight < 500 && weight >= 200) {
displayPrice = weight * 50;
} else if (weight < 1000 && weight >= 500) {
displayPrice = weight * 500;
} else if (weight < 2000 && weight >= 1000) {
displayPrice = weight * 5000;
}
} else {
if (weight < 500 && weight >= 200) {
displayPrice = weight * 20;
} else if (weight < 1000 && weight >= 200) {
displayPrice = weight * 200;
} else if (weight < 2000 && weight >= 1000) {
displayPrice = weight * 2000;
}
}
price.innerHTML = displayPrice;
}
</script>
</html>