3
I’m trying to get a value from some inputs with Javascript to show them in a specific order.
<form id="formulario" name="" method="" action="">
<p><h2 id="titulo-form">Dados do Livro</h2></p>
<p><label for="nome">Nome do Autor:</label>
<input type="text" name="nome" id="nome"maxlength="80"/></p>
<p><label for="sobre">Sobrenome do Autor:</label>
<input type="text" name="sobre" id="sobre"maxlength="80"/></p>
<p><label for="titulo">Título:</label>
<input type="text" name="titulo" id="titulo"maxlength="80"/></p>
In this case, I would like to show the order: Author’s surname > Author’s name > Title
I don’t have much experience with JS, so the basic thing I tried was to store the inputs the variables in this way, and link the generate function to the form’s Ubmit, however, I don’t know how to return it
function gerar() {
var nomeAutor = document.getElementsById('nome');
var sobreNome = document.GetElementById('sobre');
var titulo = document.getElementsById('titulo');
}
Do you want to show whenever they change? or when the page clicks? or when the form is submitted?
– Sergio
When the form is submitted
– user154181
Donizete, post attempt JS
– Leonardo Negrão