How can I get the value of a text and print on the [closed]

-3

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.

    
asked by anonymous 29.04.2014 / 13:05

2 answers

2

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:

Example Value Input - fiddle

    
29.04.2014 / 13:20
2

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;
    
09.05.2014 / 14:15