-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurd.html
More file actions
82 lines (80 loc) · 2.48 KB
/
Copy pathcurd.html
File metadata and controls
82 lines (80 loc) · 2.48 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
<!DOCTYPE html>
<html lang="en">
<head>
<style>
table, th, td{
border: 2px solid red;
}
table, td, th{
border-collapse:collapse;
}
body{
justify-content: center;
display: flex;
}
.employee-form{
height: 400px;
width:400px ;
background-color: aqua;
}
.save-button{
width: 80px;
height: 30px;
background-color: blue;
color:#fff;
border: none;
border-radius:5px;
}
</style>
<title>Curd demo</title>
</head>
<body>
<div class="employee-form">
<h1 style="text-align:center">CURD DEMO</h1>
<div style="padding:10px; margin:5px">
<form onsubmit="saveEmployee()">
<label>First name</label>
<input type="text" name="'fname" value="" id="fname"><br>
<label>Last name</label>
<input type="text" name="'lname" value="" id="lname"><br>
<label>Email</label>
<input type="email" name="email" value="" id="email">
<input type="submit" value="Save" class="save-button">
</form>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
<tbody id="data">
</tbody>
</table>
</div>
<a href="https://google.com" onclick="navigation()">Google</a>
</div>
<script>
function saveEmployee(){
var fname= document.getElementById("fname").value
var lname= document.getElementById("lname").value
var email= document.getElementById("email").value
var tbody=document.getElementById("data")
reset();
var tabledata= `<tr>
<td>${fname}</td>
<td>${lname}</td>
<td>${email}</td>
</tr>`
tbody.innerHTML = tbody.innerHTML + tabledata
}
function reset(){
document.getElementById("fname").value=""
document.getElementById("lname").value=""
document.getElementById("email").value=""
}
function navigation(){
event.preventDefault();
}
</script>
</body>
</html>