-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestion.Page
84 lines (74 loc) · 2.1 KB
/
Question.Page
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
<!DOCTYPE html>
<html>
<head>
<title>Question Page</title>
<style>
.dropdown-container {
position: relative;
display: inline-block;
width: 200px;
}
.custom-select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
cursor: pointer;
background-color: #f0f0f0;
}
.dropdown-list {
display: none;
position: absolute;
top: 100%; /* Ensures the dropdown opens below */
left: 0;
width: 100%;
background-color: #ffffff;
border: 1px solid #ccc;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
z-index: 1;
max-height: 150px;
overflow-y: auto;
}
.dropdown-list div {
padding: 8px;
cursor: pointer;
}
.dropdown-list div:hover {
background-color: #ddd;
}
.dropdown-list.show {
display: block;
}
</style>
</head>
<body>
<p>
Let's answer the question for make your health schedule!!
</p>
<p>
What type of exercise do you want?
</p>
<form action="/action_page.php">
<div class="dropdown-container">
<div class="custom-select" onclick="toggleDropdown()" id="exercise">Click the box</div>
<div class="dropdown-list" id="dropdown">
<div onclick="selectOption(this)">Running</div>
<div onclick="selectOption(this)">Cycling</div>
<div onclick="selectOption(this)">Swimming</div>
<div onclick="selectOption(this)">Walking</div>
<div onclick="selectOption(this)">Yoga</div>
</div>
</div>
</form>
<script>
function toggleDropdown() {
document.getElementById('dropdown').classList.toggle('show');
}
function selectOption(optionElement) {
// Set the selected option text in the custom-select element
document.getElementById('exercise').innerText = optionElement.innerText;
// Close the dropdown after selection
document.getElementById('dropdown').classList.remove('show');
}
</script>
</body>
</html>