Check this.
function clicked() {
var firstname = document.getElementById("fname").value;
var lastname = document.getElementById("lname").value;
document.getElementById("demo").innerHTML = "Hello " + firstname + "<br>" + "Your lat name is: " + lastname;
}
<div>
First Name: <input type="text" id="fname" value=""><br><br>
Last Name: <input type="text" id="lname" value="">
<button onclick="clicked()">Submit</button>
<p id="demo"></p>
</div>
2
solved Why does not javascript show the output when button is clicked