-
Notifications
You must be signed in to change notification settings - Fork 0
/
uid8form.html
168 lines (137 loc) · 4.47 KB
/
uid8form.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
165
166
167
168
<!DOCTYPE html>
<html>
<head>
<title>Student Registration Form</title>
<style>
body {
font-family: Arial, sans-serif;
}
h2 {
color: #333;
}
form {
margin-bottom: 20px;
}
label {
display: block;
margin-top: 10px;
}
input[type="submit"] {
margin-top: 10px;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h2>Student Registration Form</h2>
<form id="registrationForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name" ><br>
<label for="father">Father Name:</label>
<input type="text" id="father" name="father"><br>
<label for="postal">Postal Address:</label>
<input type="text" id="postal" name="postal" ><br>
<label for="personal">Personal Address:</label>
<input type="text" id="personal" name="personal" ><br>
<label>Sex:</label>
<input type="radio" id="male" name="sex" value="Male">
<label for="male">Male</label>
<input type="radio" id="female" name="sex" value="Female" >
<label for="female">Female</label><br>
<label for="city">City:</label>
<select id="city" name="city" >
<option value="">jaipur</option>
<!-- Add city options here -->
</select><br>
<label for="course">Course:</label>
<select id="course" name="course" >
<option value="">cse</option>
<!-- Add course options here -->
</select><br>
<label for="district">District:</label>
<select id="district" name="district" >
<option value="">eranakulam</option>
<!-- Add district options here -->
</select><br>
<label for="state">State:</label>
<select id="state" name="state" >
<option value="">kerala</option>
<!-- Add state options here -->
</select><br>
<label for="pincode">PinCode:</label>
<input type="text" id="pincode" name="pincode" ><br>
<label for="email">Email Id:</label>
<input type="email" id="email" name="email" ><br>
<label for="dob">DOB:</label>
<input type="date" id="dob" name="dob" ><br>
<label for="mobile">MobileNo:</label>
<input type="tel" id="mobile" name="mobile" ><br>
<input type="submit" value="Submit Form">
</form>
<div id="output" style="display: none;">
<h3>Submitted Data:</h3>
<table id="dataTable">
<thead>
<tr>
<th>Student Name</th>
<th>Date of birth</th>
<th>email</th>
<th>Mobile Number</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div id="stateInfo"></div>
</div>
<script >
document.addEventListener('DOMContentLoaded', function() {
var form = document.getElementById('registrationForm');
var output = document.getElementById('output');
var dataTable = document.getElementById('dataTable');
var stateInfo = document.getElementById('stateInfo');
form.addEventListener('submit', function(event) {
event.preventDefault();
var name = document.getElementById('name').value;
var dob = document.getElementById('dob').value;
var email = document.getElementById('email').value;
var mobile = document.getElementById('mobile').value;
var city = document.getElementById('city').value;
var state = document.getElementById('state').value;
var row = dataTable.insertRow();
var nameCell = row.insertCell();
var dobCell = row.insertCell();
var emailCell = row.insertCell();
var mobileCell = row.insertCell();
nameCell.textContent = name;
dobCell.textContent = dob;
emailCell.textContent = email;
mobileCell.textContent = mobile;
var stateData = {
'ERNAKULAM': '682020',
'ALAPUZHA': '688001',
'KOLLAM': '691001'
};
if (stateData.hasOwnProperty(city.toUpperCase())) {
var pincode = stateData[city.toUpperCase()];
stateInfo.innerHTML = 'The state should have ' + state + ', city should have ' + city + '. Rest you can add whatever you want. When these cities are selected the following pincode should be automatically added.<br>City: ' + city.toUpperCase() + ', Pincode: ' + pincode;
} else {
stateInfo.textContent = '';
}
form.reset();
output.style.display = 'block';
});
});
</script>
</body>
</html>