2
I want to know how to, instead of sending the result of the function to Alert, create a paragraph, for example. Remembering that this doubt is to help me with future projects, so I’m putting a very simple code.
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" lang="pt-br">
<title>Formulário teste</title>
<script type="text/javascript">
function enviar(){
var formulario = document.getElementById('formulario');
var nome2 = formulario.nome.value;
alert(nome2);
}
</script>
</head>
<body>
<h1>Dados para cadastro</h1>
<form id="formulario">
<label for="nome">Nome:</label>
<input id="nom" type="nome" name="nome">
<label for="cpf">CPF:</label>
<input type="cpf" name="cpf">
<label for="cep">CEP</label>
<input type="cep" name="cep">
<button onclick="enviar()">Submit</button>
</form>
<h1 id="receber"></h1>
</body>
</html>
What do you mean? It wasn’t clear
– Sam
Instead of alerting the input value, send to an HTML paragraph
– Haron Maia