-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
141 lines (114 loc) · 3.67 KB
/
Copy pathindex.html
File metadata and controls
141 lines (114 loc) · 3.67 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Student Form</title>
<style>
h1 {
text-align: center;
}
table {
margin: 30px auto;
/* center both tables */
font-size: 20px;
/* larger table text */
}
th {
text-align: center;
/* headers centered */
font-size: 22px;
}
input,
select,
button {
font-size: 20px;
padding: 6px;
}
</style>
</head>
<body>
<h1>STUDENT FORM</h1>
<table border="15" cellpadding="5">
<tr>
<th>Name</th>
<td><input type="text" id="name"></td>
</tr>
<tr>
<th>Age</th>
<td><input type="number" id="age"></td>
</tr>
<tr>
<th>Gender</th>
<td>
<input type="radio" name="gender" id="male" value="Male"> Male
<input type="radio" name="gender" id="female" value="Female"> Female
</td>
</tr>
<tr>
<th>Course</th>
<td>
<select id="course" style="width: 100%;">
<option>-- Select Course --</option>
<option>BCA</option>
<option>MCA</option>
<option>BSc CS</option>
</select>
</td>
</tr>
<tr>
<th>Email</th>
<td><input type="email" id="email"></td>
</tr>
<tr>
<td colspan="2" align="center">
<button onclick="save()" style="width: 100%;background-color: aqua;">Save</button>
</td>
</tr>
</table>
<br><br>
<table border="10" cellpadding="8" id="output">
<tr>
<th>NAME</th>
<th>AGE</th>
<th>GENDER</th>
<th>COURSE</th>
<th>E-MAIL</th>
<th>ACTION</th>
</tr>
</table>
<script>
function save() {
var name = document.getElementById("name").value;
var age = document.getElementById("age").value;
var course = document.getElementById("course").value;
var email = document.getElementById("email").value;
var gender = "";
if (document.getElementById("male").checked) {
gender = "Male";
}
if (document.getElementById("female").checked) {
gender = "Female";
}
var table = document.getElementById("output");
var row = table.insertRow();
row.insertCell(0).innerHTML = name;
row.insertCell(1).innerHTML = age;
row.insertCell(2).innerHTML = gender;
row.insertCell(3).innerHTML = course;
row.insertCell(4).innerHTML = email;
row.insertCell(5).innerHTML = "<button onclick='del(this)' style='background-color:red;color:white;'>Delete</button>";
clearForm(); // ← CLEAR AFTER SAVE
}
function del(btn) {
btn.parentNode.parentNode.remove();
}
function clearForm() {
document.getElementById("name").value = "";
document.getElementById("age").value = "";
document.getElementById("course").selectedIndex = 0;
document.getElementById("email").value = "";
document.getElementById("male").checked = false;
document.getElementById("female").checked = false;
}
</script>
</body>
</html>