Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
How can I convert the value written in HTML input to the string variable?

var imie = document.getElementById("imim");

function wypisz_imie() {
  document.getElementById("powitanie").innerHTML = "Czesc!" + imie;
}
<!DOCTYPE>
<html>

<head>
  <title>My city v1.0</title>
</head>

<body>
  <script type="text/javascript" src="skrypt.js"></script>
  <h2>Wpisz jak masz na imie</h2>
  <input type="text" id="imim" value="" />
  <input type="submit" id="potwim" value="potwierdz" onclick="wypisz_imie()" />
  <h1 id="powitanie"></h1>
</body>

</html>

Sorry for my English cause i'm from Poland and i'm new user. I'll be thankfull for answers!

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use document.getElementById("imim").value to get the text in the text field. It's up to you what to do from there!

about 4 years ago · Juan Pablo Isaza Relatório

0

imie will return the input element so you should use value property like this:

var imie = document.getElementById("imim");
function wypisz_imie()
{
    document.getElementById("powitanie").innerHTML = "Czesc!" + imie.value;
}

imie.value will return the value of input. check w3s.

but every time the value will return "", to solve this problem you should access input every time call function to return input with new value like this:

function wypisz_imie()
{
    var imie = document.getElementById("imim");
    document.getElementById("powitanie").innerHTML = "Czesc!" + imie.value;
}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda