-2
I am trying to print a value that was typed by user from a textfield
, for example a name field.
But after I get it, I want to print that name.
-2
I am trying to print a value that was typed by user from a textfield
, for example a name field.
But after I get it, I want to print that name.
3
To get the entered value, you can do as much by javascript
as jquery
.
Having the input:
<input type="text" id="inputValor" />
Javascript:
document.getElementById('inputValor').value;
Jquery:
$('#inputValor').val()
By both examples you can get the typed text in the input. I leave Jsfiddle with full example to see:
3
Whereas 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;
Browser other questions tagged javascript html
You are not signed in. Login or sign up in order to post.
Print a value where? Console? Alert? Other input field? Try to better formulate your question. If possible, put part of your code that is in doubt.
– Felipe Avelar
for
imprimir
you can use aalert('')
or place the value inside an html element (such as a text). You can also print on the console (used for development)– Michel Ayres