What is the method to display my input value within my application interface rather than triggering an alert popup?

Hi there, I am seeking assistance with my GUI code. I want the input value to be displayed as text on the screen, or even better, to look like a chatroom so that I can integrate a simple chatbot later on. My main goal is to have the texts show up in the blue section or the "text display" section. If someone could help me with this, I would greatly appreciate it. Thank you.

const { app, BrowserWindow, ipcMain } = require("electron");

let win = null;

const createWindow = () => {
  win = new BrowserWindow({

    width: 1280,
    height: 720,
    resizable: false,
    webPreferences: {
      nodeIntegration: true,
    },
  });

  win.loadFile("index.html");
};

app.whenReady().then(createWindow);
body {
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background-color: white ;
}

input {
    margin-bottom: -40px;
    width: 738px;
    height: 40px;
    border: none;
    background-color: rgba(0, 0, 0, 0.76);
    color: white;
    font-size: 18px;
}

button {
    width: 155px;
    height: 42px;
    border: none;
    background-color: #000000;
    color: white;
    font-size: 18px;
    cursor: pointer;
}

buttonSettings {
    width: 263px;
    height: 100px;
    background-color: #ff0000;
    color:white;
    margin: 0 auto;
    padding: 20px;
    display: inline-block;
    line-height: 100px;
    text-align: center;
    font-size: 26px;
    cursor: pointer;
}

textDisplay {
    width:930px;
    height: 588px;
    background-color: steelblue;
    color: white;
    margin: 0 auto;
    padding: 20px;
    font-size: 18px;
    display: inline-block;
    overflow-y: scroll;
}

buttonMicrophone {
    width: 200px;
    height: 1px;
    border: none;
    padding: 18px;
    background-color: #000000;
    color: white;
    font-size: 18px;
    cursor: pointer;
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport", content="width=device-width, initial-scale=1.0">
        <title>Ali face</title>
        <link rel="stylesheet" href="style.css">
        <script defer src="render.js"></script>
    </head>
    <body>
        
        <div class="form-group" style="float:right; position: absolute;bottom:0; right:0;">
            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                <input type="text" placeholder="say anything" id="myInput">
                <buttonMicrophone id="speech" onclick="speechToText()">mic</buttonMicrophone>
                <button id="send" onclick="getInputValue();">Send</button>   
                <script>
                    function getInputValue(){
                        //Selecting the input element and get its value 
                         var inputVal = document.getElementById("myInput").value;
                        
                        // Displaying the value
                        <h1>(inputVal);</h1>
                    }
                </script>
            </div>
        </div>
        <div class="form-group" style="float:left; position: absolute;top:0; left:0;">
            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
               <buttonSettings>Settings</buttonSettings> 
            </div>
        </div>
        <div class="from-group" style="float:right; position: absolute;top:0; right:0;">
            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                <textDisplay></textDisplay>
            </div>
        </div>
    </body>
</html>

Answer №1

 <textDisplay id="text_area"></textDisplay>

After that, update the following function

<script>
                        function getValue(){
                            //Accessing the input element and retrieving its value 
                             var val = document.getElementById("myInput").value;
                
                           $('#text_area').text(val)
                        }
                    </script>

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

JavaScript Radio Buttons

Below are the different radiobuttons: Apple <input type="radio" id="one" name="apple" data-price="10" value="light"/> Light <input type="radio" id="two" name="apple" data-price="20" value="dark" /> Dark <input type="text" id="appleqty" name ...

What is the process for accessing and storing an uploaded image in a Next.js application?

How can I retrieve an uploaded image in a next.js API route and save it to the public folder? My frontend is all set up, and I'm currently uploading images to an endpoint using plain JavaScript. Below is the onSubmit function for uploading images. Ple ...

Implementing XOR operation in a jQuery script

In need of a small script modification where one value needs to be XORed. A previous suggestion no longer applies due to changes made in the script. <input type='button' value='Ein / Aus' class='taster' csv='Lampe&apo ...

The MongoDB operator "$in" does not recognize the type array that currently exists in the field

When attempting to execute an aggregate query in mongodb, I encountered an issue with the "$in" operator stating that the field passed is not recognized as an array. Here is the aggregate query being used: [ { '$match': { 'isVis ...

TypeScript: creating an interface property that relies on the value of another

Is it feasible to have an interface property that relies on another? For instance, consider the following: const object = { foo: 'hello', bar: { hello: '123', }, } I wish to ensure that the key in bar corresponds to the value of f ...

The fail() handler will be triggered even when receiving an HTTP status code of 200 or

Here is a snippet of my code: function dlgEditPhase_okClicked(dlgEditPhase, event) { $.post("/overview/phase/"+dlgEditPhase.projectId, JSON.stringify({ "phaseName": dlgEditPhase.phaseName, "begi ...

Efficient Pagination with React Redux

Case One: I am currently implementing server-side pagination in Rails using React for the front-end and Redux for state management. I have completed all the necessary setup, and the only thing left is to pass the newly generated URL to fetch the new data. ...

Opting for frontend technologies such as React or Angular to update a Silverlight application containing over 1000 unique forms and views

We are in the process of transitioning our Silverlight application to modern web technologies like React or Angular due to the impending end of life for Silverlight by the end of this year. We are seeking advice on selecting the most suitable frontend tec ...

Struggling with slow loading times for Three.JS GLTF models? Discover ways to optimize and speed up the load time

My GLTF model (9mb) is loading slowly in ThreeJS. It takes about 4-5 seconds to load on my PC and around 11 seconds on my iPhone. I'm looking for ways to speed up the rendering times. Surprisingly, examples from the ThreeJS website load faster than my ...

Can you tell me the locations of the src/js and build/js directories?

Just starting out and seeking guidance. I am currently working with Node v4.2.1 and Gulp 3.9.0 on a Windows 7 machine, following along with a tutorial to familiarize myself with the task runner Gulp. I'm attempting to concatenate tasks but I seem to ...

Preventing users from navigating away from the page without choosing an answer in a React application

My dilemma involves the implementation of a question component, where I aim to prevent users from leaving a page without selecting an answer. Below is my question component: import React, { Component } from 'react'; import { Link } from 're ...

Run the function after the onclick function has finished executing

I'm currently working on diagnosing an issue with this application. There is an anchor tag that contains the following code: onclick="javascript: return ShowItemDiscussion();" This code is located in a separate JavaScript file. I am attempting to ...

Angular factory transforming service

I am looking to transform the 'i18n' function into a factory in order to return a value instead of just setting it. Any suggestions or tips would be greatly appreciated! services.factory('i18nFactory', function() { var language = ...

Strategies for transferring information to a different component in a React application

Building a movie site where users can search for films, click on a card, and access more details about the film is proving challenging. The problem lies in transferring the film details to the dedicated details page once the user clicks on the card. An onc ...

Comparing the use of Next.js static assets from the public folder with cloud-based storage solutions

Typically, in Next.js (or React) cloud-based storage solutions are commonly utilized for storing media files such as images. My inquiry is, what prevents us from saving images as static assets in the public folder and accessing them directly in our appli ...

What are the steps to utilizing the $document service in AngularJS?

I am a complete beginner when it comes to AngularJS and JavaScript in general, and I find myself a bit confused about the usage of $document. From what I understand, $document provides access to some JQuery functions. So, if I want to remove an element tha ...

Disabling 'Input Number' feature is ineffective in Firefox browser

Is there a way to prevent the input value from changing when the up or down arrow is held, even if the input is disabled? I want to retain the arrows without allowing this behavior on Firefox. Give it a try: Press the up arrow. After 5 seconds, the input ...

Unexpected issue with Ionic 4 subarray returning as undefined even though the index is accurate

When attempting to use console.log to view the value, I noticed that the value of noticeSet2[index] is undefined. However, when I print noticeSet, all the data in the array is displayed. Additionally, after printing the index using console.log, it correctl ...

Tips for documenting curried functions using Js docs

I'm encountering issues while trying to use Js docs for generating static documentation of my project. When attempting to run the js doc command, I am faced with numerous parse errors specifically in areas where I have curried functions. Strangely, my ...

"Implementing Notifications in Mongoose: A Step-by-Step Guide

My current user schema is set up as follows: const Schema = mongoose.Schema; const bcrypt = require("bcryptjs"); const userSchema = new Schema( { email: { type: String, required: true, index: { unique: true } }, ...