Create a text input that allows a user to enter a username Create a button that when clicked stores that username in sessionStorage Create another button that when clicked pulls the username back from session Storage

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
●
●
●
Create a text input that allows a user to enter a username
Create a button that when clicked stores that username in session Storage
Create another button that when clicked pulls the username back from
session Storage
Transcribed Image Text:● ● ● Create a text input that allows a user to enter a username Create a button that when clicked stores that username in session Storage Create another button that when clicked pulls the username back from session Storage
Expert Solution
Step 1: Algorithm :

Algorithm: User Input and sessionStorage

1. Start
2. Create an HTML document.
3. Add the necessary HTML structure:
   a. Create an input field with an id of "username" and a placeholder text.
   b. Create two buttons with ids "storeButton" and "retrieveButton".
   c. Create a paragraph element with an id of "output".
4. Add a script section inside the HTML document.
5. Inside the script section, define the following functions:
   a. `storeUsername` function:
      i. Get the value of the input field with the id "username".
      ii. Check if the entered username is not empty.
      iii. If the username is not empty, store it in sessionStorage with the key "username".
      iv. Display a message indicating that the username has been stored in sessionStorage.
      v. If the username is empty, display an error message.
   b. `retrieveUsername` function:
      i. Retrieve the username from sessionStorage using the key "username".
      ii. Check if a username was found in sessionStorage.
      iii. If a username is found, display it on the page.
      iv. If no username is found, display a message indicating that no username is stored in sessionStorage.
6. Add event listeners to the "storeButton" and "retrieveButton" elements:,a. Create an input field with an id of "username" and a placeholder text.
   b. Create two buttons with ids "storeButton" and "retrieveButton".
   c. Create a paragraph element with an id of "output".
4. Add a script section inside the HTML document.
5. Inside the script section, define the following functions:
   a. `storeUsername` function:
      i. Get the value of the input field with the id "username".
      ii. Check if the entered username is not empty.
      iii. If the username is not empty, store it in sessionStorage with the key "username".
      iv. Display a message indicating that the username has been stored in sessionStorage.
      v. If the username is empty, display an error message.
   b. `retrieveUsername` function:
      i. Retrieve the username from sessionStorage using the key "username".
      ii. Check if a username was found in sessionStorage.
      iii. If a username is found, display it on the page.
      iv. If no username is found, display a message indicating that no username is stored in sessionStorage.
6. Add event listeners to the "storeButton" and "retrieveButton" elements:
   a. When the "storeButton" is clicked, call the `storeUsername` function.
   b. When the "retrieveButton" is clicked, call the `retrieveUsername` function.
7. End


trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Windows
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education