Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!