I'm trying to print a value that was typed per user from a textfield
, for example a name field.
But after I get it, I want to print the name.
I'm trying to print a value that was typed per user from a textfield
, for example a name field.
But after I get it, I want to print the name.
In order to get the typed value, you can either javascript
or jquery
.
Having input:
<input type="text" id="inputValor" />
Javascript:
document.getElementById('inputValor').value;
Jquery:
$('#inputValor').val()
For both of these examples, you can get the text typed in the input. I leave JSFiddle with full example to see:
Considering that the id of the textfield element is id1 :
HTML:
<input id="id1" type="text"/>
Javascript:
//Obtem o valor do elemento textfield e armazena na variável "valor"
var valor = document.getElementById('id1').value;
//Para imprimir na página
document.write(valor);
//Para imprimir em um elemento específico
document.getElementById('IdDoElementoEspecifico').innerText = valor
//Para imprimir em um Input Text
document.getElementById('IdDoElementoInputText').value = valor;