Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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
expand button
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
Check Mark
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


Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education