-
Notifications
You must be signed in to change notification settings - Fork 0
/
surveyform.html
164 lines (150 loc) · 6.17 KB
/
surveyform.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Survey Form</title>
<style>
body {
background-color: #0D99E8;
font-family: Arial, sans-serif;
}
h1{
color: white;
align-items: center;
text-align: center;
}
.fname{
display: grid;
grid-template-columns: 6fr 6fr;
}
#firstName{
height: 30px;
border: 2px solid black;
}
#email{
height: 30px;
border: 2px solid black;
}
.container {
background-color: white;
color: black;
max-width: 500px;
margin: 0 auto;
padding: 20px;
border: 2px solid black;
}
label, input, select, div {
margin-bottom: 10px;
}
#profession{
height: 100px;
width: 450px;
border: 2px solid black;
}
#submitBtn{
background-color: #0D99E8;
border: 2px solid black;
font-size: 20px;
border-radius: 7px;
}
#resetBtn{
background-color: #0D99E8;
border: 2px solid black;
font-size: 20px;
border-radius: 7px;
}
footer{
align-items: center;
text-align: center;
}
.copyR{
color: yellow;
}
.w3{
color: black;
}
</style>
</head>
<body>
<h1>Customer Survey Form</h1>
<div class="container">
<form id="surveyForm">
<div class="fname">
<div>
<label for="firstName"><b>Name</b></label><br><br>
<input type="text" id="firstName" required autofocus><br>
</div>
<div>
<label for="email"><b>Email:</b></label><br><br>
<input type="email" id="email" required><br>
</div>
</div>
<label>In this first time You are using or Products & service ?</label><br><br>
<input type="checkbox" id="male" name="gender" value="male">
<label for="male">Yes</label>
<input type="checkbox" id="female" name="gender" value="female">
<label for="female">No</label><br><br>
<label>Would you suggession to your friends and collegue?</label><br><br>
<input type="checkbox" id="male" name="gender" value="male">
<label for="male">Yes</label>
<input type="checkbox" id="female" name="gender" value="female">
<label for="female">No</label><br><br>
<label>How satisfied are you with our company overall ?</label><br><br>
<input type="checkbox" id="male" name="gender" value="male">
<label for="male">Satisfied</label>
<input type="checkbox" id="female" name="gender" value="female">
<label for="female">Undecided</label>
<input type="checkbox" id="female" name="gender" value="female">
<label for="female">Unsatisfied</label><br><br>
<label for="profession">Do you have suggession to improve our service ?</label><br><br>
<input type="text" id="profession" required><br><br>
<button type="submit" id="submitBtn">Submit</button>
<button type="button" id="resetBtn">Reset</button>
</form>
</div>
<footer>
<span class="copyR">©2018 Customer Survey Form.All Rights Reserved|Design by</span> <span class="w3">W3Layouts</span>
</footer>
<div id="popup" style="display: none;">
<h2>Form Data</h2>
<div id="popupContent"></div>
<button id="closePopup">Close</button>
</div>
<script>
document.getElementById("surveyForm").addEventListener("submit", function (event) {
event.preventDefault();
const firstName = document.getElementById("firstName").value;
const dob = document.getElementById("dob").value;
const country = document.getElementById("country").value;
const gender = [...document.querySelectorAll('input[name="gender"]:checked')].map(checkbox => checkbox.value);
const profession = document.getElementById("profession").value;
const email = document.getElementById("email").value;
const mobile = document.getElementById("mobile").value;
if (!firstName || !lastName || !dob || !country || gender.length === 0 || !profession || !email || !mobile) {
alert("Please fill in all the required fields.");
return;
}
const popupContent = document.getElementById("popupContent");
popupContent.innerHTML = `
<p><strong>First Name:</strong> ${firstName}</p>
<p><strong>Last Name:</strong> ${lastName}</p>
<p><strong>Date of Birth:</strong> ${dob}</p>
<p><strong>Country:</strong> ${country}</p>
<p><strong>Gender:</strong> ${gender.join(", ")}</p>
<p><strong>Profession:</strong> ${profession}</p>
<p><strong>Email:</strong> ${email}</p>
<p><strong>Mobile Number:</strong> ${mobile}</p>
`;
document.getElementById("popup").style.display = "block";
});
document.getElementById("resetBtn").addEventListener("click", function () {
document.getElementById("surveyForm").reset();
});
document.getElementById("closePopup").addEventListener("click", function () {
document.getElementById("popup").style.display = "none";
document.getElementById("surveyForm").reset();
});
</script>
</body>
</html>