Is there a way to show user input text in a typing animation with additional predetermined text?

Using the prompt function, I am gathering input and storing it in variable "a". Here is the code snippet:

<script type="text/javascript" language="Javascript">
    var a=prompt("Please Enter Your Name 👇👇👇👇👇");
</script>

After storing the text in "a", I aim to display it along with some additional text like "blah blah blah" in a single line with a typewriter effect using CSS.

html {
  min-height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  background-repeat: no-repeat;
  /* background-attachment: fixed; */
  background-image: radial-gradient(black, white);
}

/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
  color: #fff;
  font-family: monospace;
  overflow: hidden; /* Ensures the content is not revealed until the animation */
  border-right: .15em solid orange; /* The typewriter cursor */
  white-space: nowrap; /* Keeps the content on a single line */
  margin: 0 auto; /* Gives that scrolling effect as the typing happens */
  letter-spacing: .15em; /* Adjust as needed */
  animation: 
  typing 3.5s steps(40, end),
  blink-caret .75s step-end infinite;
}

/* The typing effect */
@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

/* The typewriter cursor effect */
@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: orange; }
}
<body>
  <script type="text/javascript" language="Javascript">
    var a = prompt("Please Enter Your Name 👇👇👇👇👇");
  </script>
  <div class="typewriter">
    <h1>
      <script>
        document.write(a)
      </script>blah blah
    </h1>
  </div>
</body>

When running this code, only the "blah blah blah" animation appears instead of the actual text stored in "a".

Answer â„–1

It looks like there is a typo in your code, make sure to check the developer console for any errors.

{
  "message": "Uncaught ReferenceError: docment is not defined",
  "filename": "https://stacksnippets.net/js",
  "lineno": 60,
  "colno": 17
}

html {
      min-height: 100%;
      overflow: hidden;
}
body
    {
        display: flex;
        background-repeat: no-repeat;
       /* background-attachment: fixed;*/
        background-image: radial-gradient(black,white);
    }

/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
  color: #fff;
  font-family: monospace;
  overflow: hidden; /* Ensures the content is not revealed until the animation */
  border-right: .15em solid orange; /* The typwriter cursor */
  white-space: nowrap; /* Keeps the content on a single line */
  margin: 0 auto; /* Gives that scrolling effect as the typing happens */
  letter-spacing: .15em; /* Adjust as needed */
     animation: 
    typing 3.5s steps(40, end),
    blink-caret .75s step-end infinite;
}

/* The typing effect */
@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

/* The typewriter cursor effect */
@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: orange; }
}
}
<html>
<head>
<!--Google Analytics code Here -->
<title>HAPPY INDEPENDANCE DAY</title>
<link rel="stylesheet" href="full.css">
   
</head>
<body>
    <script type="text/javascript" language="Javascript">
                 var a=prompt("Please Enter Your Name 👇👇👇👇👇");
                </script>
<div class="typewriter">
    <h1><script>document.write(a) </script> blah blah</h1>
</div>
</body>
</html>

Answer â„–2

Follow these steps.

let name = prompt("Please Enter Your Name 👇👇👇👇👇");
                 document.getElementById("name").innerHTML = name;
html {
      min-height: 100%;
      overflow: hidden;
}
body
    {
        display: flex;
        background-repeat: no-repeat;
       /* background-attachment: fixed;*/
        background-image: radial-gradient(black,white);
    }

/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
  color: #fff;
  font-family: monospace;
  overflow: hidden; /* Ensures the content is not revealed until the animation */
  border-right: .15em solid orange; /* The typwriter cursor */
  white-space: nowrap; /* Keeps the content on a single line */
  margin: 0 auto; /* Gives that scrolling effect as the typing happens */
  letter-spacing: .15em; /* Adjust as needed */
     animation: 
    typing 3.5s steps(40, end),
    blink-caret .75s step-end infinite;
}

/* The typing effect */
@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

/* The typewriter cursor effect */
@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: orange; }
}
}
<html>
<head>
<!--Google Analytics code Here -->
<title>HAPPY INDEPENDANCE DAY</title>
<link rel="stylesheet" href="full.css">
   
</head>
<body>

<div class="typewriter">
    <h1 id="name"></h1>
</div>
</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Include an item in a Vuetify model's array of objects

Currently, I am attempting to store the value of a dynamically loaded radio button into an array of objects. These radio buttons serve as options for a set of questions within a form, and my desired output is as follows: [{"question1":{ " ...

Passing form data to PHP using AJAX in CodeIgniter Framework

I'm facing an issue with my HTML structure which is as follows: <form method="POST"> Name : <input id="asgname" type="text"> <br> Description : <input id="asgdescription" type="text"> <br> <a href="#" id=" ...

ASP.NET Script Bundling delivers combined files, although receiving a 404 response code

I am currently working on a c# ASP.NET web application. I have successfully implemented JS bundling and made sure that everything is properly configured. Despite checking numerous similar errors on stackoverflow, I seem to be facing an issue. When I enter ...

The issue with CSS and JavaScript is causing the appended elements to not display properly in PHP code

I am currently facing issues with retrieving the grandchildren from my database table named referrals. Surprisingly, my code successfully retrieves the username of my grandchildren, but it does not display below the line of my child and there are no errors ...

JavaScript: Adjust DIV Width Based on Window Height

Is there a way to make the width of a div equal to the height of the window in jquery? I attempted this method: <script type="text/javascript"> $(".rt-container").style.width = $(window).height(); </script> Unfortunately, it did not work. I ...

Avoiding data type conversion in JavaScript/TypeScript

Currently delving into the world of JavaScript, I come from a background of working with statically typed languages. Naturally, I opted to dive into TypeScript instead of starting directly with JS. While TypeScript is great and addresses many issues presen ...

Is there a way for users to share their thoughts in response to the posts of

I'm looking to implement a feature that allows users to add comments on posts with an "add comment" button similar to what you see in platforms like Facebook. When the button is clicked, a small input box should open up and display the comment below t ...

Tips for condensing text using ellipsis and Angular-FlexLayout

I am working on a flex row setup that includes three nested flex rows. Within the second row, I need to display a title that should not be shortened, and a text that should be truncated. Additionally, the first and last row must maintain a fixed width with ...

Is it permissible to have <ul> tags within an H1 element?

I am curious about whether adding a list inside an H1 heading could cause any issues: <h1> <ul> <li><a href="...">some link</a></li> <li><a href="...">another link</a></li> <li>curre ...

My Dialogflow chatbot is having trouble deploying JavaScript fulfillment code

My attempt to publish my fulfillment code created on the Inline Editor using Dialogflow and Google Cloud Console has been met with refusal. Here is a snippet of the code from my index.js file: 'use strict'; const functions = require(&apo ...

How come the use of a timeout causes the this variable to seemingly lose its reference?

What is the reason why this: myelements.mouseenter(function() { clearTimeout(globaltimeoutvar); globaltimeoutvar = setTimeout(function() { var index = myelements.index(this); console.log(index); // -1 }, 150); }); Returns -1, while this: m ...

Extracting information from an ENORMOUS Array

Let's start with my code snippet, featuring an array: var UserProfiles = [{ userProfileID: 1, firstName: 'Austin', lastName: 'Hunter', email: 'test', token: '', platform: 'android ...

What steps do I need to take in order to trigger the modal by clicking on the delete button?

I am in need of assistance regarding opening a modal that asks for confirmation before deleting a client. I have a function called openModal to open the modal, but I am unsure how to trigger this function within the code. The file ClientList.js looks some ...

I am looking to sort the salary information based on the radio button selected

When I click on the radio button in the code, I want to filter the data of the salary Array. The rendered data should be filtered according to the text on the radio button. The check box Array filtering is working fine, but after applying the same concept, ...

How can I transfer PHP/MYSQL information into a PDF?

I've recently developed a Student Information Form that is linked to a MYSQL database. Now, I'm looking to export all the collected data from the MYSQL DB into a PDF file. Is there a way to accomplish this task? Any suggestions on how to achieve ...

What is the best way to load data that is essential for the entire functionality of an AngularJs Application?

Within my application, there exists essential data that is utilized by various controllers to carry out their functions. For instance, the user and other entities must make REST calls to the server. Currently, I have an AppController (app.js) responsible ...

Acquiring the user's IP address using Socket.io version 1.0 and Express

Is there a way to retrieve the IP address of a connecting client in socket.io? Unfortunately, the method outlined in this link does not work for Socket.io v1.0: Get the client's IP address in socket.io. It simply returns undefined. I also attempted t ...

Switching from Wordpress to Django and completely revamping the website using only Django

I have a webpage that currently has wordpress.org preinstalled, but I have never utilized it. Now, as I am exploring django, I am interested in using it to build my website instead of relying on wordpress. Can someone guide me on how to transition from wo ...

Transmit a JavaScript object using the $.ajax method

My goal is to pass a complex JavaScript object like the one below through a $.ajax request : var o = { a: 1, b: 'dummy string', c: ['a', 1, {}], d: {dd: 1}, e: new Date(), f: function() { console.log(&ap ...

Prevent a specific item from being included in an Electron list using JavaScript

When extracting filenames from a directory, this code is currently being used: getFilenameList = () => { let select = document.getElementById("filenameSelect"); let options = []; fs.readdirSync(folderUrl).forEach(file => { options.pus ...