How to store and deal with big chuncks of text between Javascript and HTML

60
January 24, 2021, at 2:40 PM

So , I'm using HTML , css and JavaScript, I did a form , where the user will give different data, like name , adress , ID number , etc and I want to introduce those values into a preformatted text (like a renting contract)... Should be easy , right?

What I did :

1 - I have created an HTML form which will take in info from the user , like name, adress , etc

2 - I will store the data provided into JavaScript variables.

let ProprietarioName;
let ArrendatarioName;
let Duracao;
function UpdateVariables()
{
    Proprietario = document.getElementById("ProprietarioNome").value;
    Arrendatario = document.getElementById("ArrendatarioNome").value;
    Duracao = document.getElementById("Duracao").value;
    console.log(Proprietario);
    console.log(Arrendatario);
    console.log(Duracao);
}

3 - Introduce the variables within the location desired of the text.

What I want to know :

4 - The text is quite long , I dont know where to save it or how. How should I handle a big text like that of a contract , if I can't save it to a variable or an array or ... I don't know, something!

5 - Where should I save that text (let's say ipssum lorem) so that then I can introduce the variable inside that text? Into the HTML file or the JavaScript file ?

This is a very noobs question , sorry.

Answer 1

Two ideas:

  1. Save in hidden textarea tags
<textarea id="ProprietarioNome" style="display: none;"></textarea>
  1. Save data to local storage. https://developer.mozilla.org/en-US/docs/Web/API/Storage . The advantage over local storage is that it persists when pages are reloaded.
READ ALSO
Blinking Text If checkbox is checked to true

Blinking Text If checkbox is checked to true

I am trying to create when user check checkbox to yes(true) in Index Page Emergency column needs to flash text something like Emergency But unfortunately I try couple of methods but unsuccessfullyHere is so far what I did

66
how to make a mysql query and turn it into an array in php

how to make a mysql query and turn it into an array in php

if I have a query that looks like this in php

56
MacOS Big Sur 11.1 can&#39;t launch eclipse installer

MacOS Big Sur 11.1 can't launch eclipse installer

I updated my MacOS to Big Sur 111 and I tried to download Eclipse IDE for Java Developers, and when I try to run the Eclipse Installer, it keep spinning at the Mac dock and nothing happens at all

109