tjwrld commited on
Commit
34e1e4b
·
verified ·
1 Parent(s): 448b7a0

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +93 -96
index.html CHANGED
@@ -1,96 +1,93 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Store Your Name</title>
7
- <style>
8
- body {
9
- font-family: Arial, sans-serif;
10
- display: flex;
11
- justify-content: center;
12
- align-items: center;
13
- height: 100vh;
14
- margin: 0;
15
- background-color: #f0f8ff;
16
- }
17
-
18
- .container {
19
- text-align: center;
20
- padding: 20px;
21
- border-radius: 10px;
22
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
23
- background-color: #ffffff;
24
- }
25
-
26
- h1 {
27
- color: #333;
28
- }
29
-
30
- input[type="text"] {
31
- padding: 10px;
32
- font-size: 16px;
33
- border: 1px solid #ccc;
34
- border-radius: 5px;
35
- width: 80%;
36
- margin-bottom: 20px;
37
- }
38
-
39
- button {
40
- padding: 10px 20px;
41
- font-size: 16px;
42
- border: none;
43
- background-color: #4CAF50;
44
- color: white;
45
- border-radius: 5px;
46
- cursor: pointer;
47
- transition: background-color 0.3s;
48
- }
49
-
50
- button:hover {
51
- background-color: #45a049;
52
- }
53
-
54
- .greeting {
55
- margin-top: 20px;
56
- font-size: 20px;
57
- font-weight: bold;
58
- color: #333;
59
- }
60
- </style>
61
- </head>
62
- <body>
63
-
64
- <div class="container">
65
- <h1>Welcome! What's your name?</h1>
66
- <input type="text" id="nameInput" placeholder="Enter your name" />
67
- <button onclick="storeName()">Submit</button>
68
- <p class="greeting" id="greetingMessage"></p>
69
- </div>
70
-
71
- <script>
72
- function storeName() {
73
- var name = document.getElementById('nameInput').value;
74
- if (name) {
75
- localStorage.setItem('userName', name);
76
- window.location.href = 'question.html'; // Redirect to question.html
77
- } else {
78
- alert('Please enter your name');
79
- }
80
- }
81
-
82
- // Check if name is already stored in localStorage
83
- window.onload = function() {
84
- var storedName = localStorage.getItem('userName');
85
- if (storedName) {
86
- displayGreeting(storedName);
87
- }
88
- }
89
-
90
- function displayGreeting(name) {
91
- document.getElementById('greetingMessage').textContent = 'Hello, ' + name + '!';
92
- }
93
- </script>
94
-
95
- </body>
96
- </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Store Your Name</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ height: 100vh;
14
+ margin: 0;
15
+ background-color: #f0f8ff;
16
+ }
17
+
18
+ .container {
19
+ text-align: center;
20
+ padding: 20px;
21
+ border-radius: 10px;
22
+ box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
23
+ background-color: #ffffff;
24
+ }
25
+
26
+ h1 {
27
+ color: #333;
28
+ }
29
+
30
+ input[type="text"] {
31
+ padding: 10px;
32
+ font-size: 16px;
33
+ border: 1px solid #ccc;
34
+ border-radius: 5px;
35
+ width: 80%;
36
+ margin-bottom: 20px;
37
+ }
38
+
39
+ button {
40
+ padding: 10px 20px;
41
+ font-size: 16px;
42
+ border: none;
43
+ background-color: #4CAF50;
44
+ color: white;
45
+ border-radius: 5px;
46
+ cursor: pointer;
47
+ transition: background-color 0.3s;
48
+ }
49
+
50
+ button:hover {
51
+ background-color: #45a049;
52
+ }
53
+
54
+ .greeting {
55
+ margin-top: 20px;
56
+ font-size: 20px;
57
+ font-weight: bold;
58
+ color: #333;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body>
63
+
64
+ <div class="container">
65
+ <h1>Welcome! What's your name?</h1>
66
+ <input type="text" id="nameInput" placeholder="Enter your name" />
67
+ <button onclick="storeName()">Submit</button>
68
+ <p class="greeting" id="greetingMessage"></p>
69
+ </div>
70
+
71
+ <script>
72
+ function storeName() {
73
+ var name = document.getElementById('nameInput').value;
74
+ if (name) {
75
+ localStorage.setItem('userName', name);
76
+ window.location.href = 'question.html'; // Redirect to question.html
77
+ } else {
78
+ alert('Please enter your name');
79
+ }
80
+ }
81
+
82
+ // Check if name is already stored in localStorage
83
+ window.onload = function() {
84
+ var storedName = localStorage.getItem('userName');
85
+ if (storedName) {
86
+ displayGreeting(storedName);
87
+ }
88
+ }
89
+
90
+ </script>
91
+
92
+ </body>
93
+ </html>