-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
140 lines (120 loc) · 3.18 KB
/
index.html
File metadata and controls
140 lines (120 loc) · 3.18 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Profile Form</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.form-container {
margin: 0 20px;
}
form {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
padding: 20px;
width: 100%;
box-sizing: border-box;
margin-top: 20px;
display: flex;
}
.column-left {
flex: 1;
padding-right: 20px;
}
.column-right {
flex: 1;
padding-left: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: bold;
}
input, select {
width: 100%;
padding: 10px;
margin-bottom: 16px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
button {
background-color: #4caf50;
color: #fff;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
img {
max-width: 100%;
height: auto;
margin-bottom: 16px;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="form-container">
<form action="" id="profileForm">
<div class="column-left">
<label for="name">Name:</label>
<input type="text" name="name" id="name" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" required>
<label for="gender">Gender:</label>
<select name="gender" id="gender" required>
<option value="male">male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
<label for="age">Age:</label>
<input type="number" name="age" id="age" required>
<button type="button" onclick="submitForm()">Submit</button>
</div>
<div class="column-right">
<label for="photo">Profile Picture:</label>
<input type="file" name="photo" id="photo" onchange="displayProfilePic()">
<img src="#" alt="Profile Picture" style="display: none;" id="profilePic">
</div>
</form>
</div>
<script>
function displayProfilePic() {
const input = document.getElementById('photo');
const img = document.getElementById('profilePic');
if (input.files && input.files[0]) {
const reader = new FileReader();
reader.onload = function (e) {
img.src = e.target.result;
img.style.display = 'block';
};
reader.readAsDataURL(input.files[0]);
}
}
function submitForm() {
const formData = new FormData(document.getElementById('profileForm'));
for (const pair of formData.entries()) {
console.log(pair[0] + ': ' + pair[1]);
}
}
</script>
</body>
</html>