My html code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Huffman Coding</title>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<span>Huffman <span>Coding</span></span>
<br><br><br>
<div id="temp">
Enter input string here <br><br><br>
<form action="" id="input">
<input id="input-string" name="input_string" type="search">
<br>
<button type="submit" onclick="calcHash()">Submit</button>
</form>
</div>
<p id="demo"></p>
</body>
</html>
My Js code:
function calcHash() {
var input = document.getElementById("input");
var text = "";
for (let i = 0; i < input.length; i++) {
text += input.element[i].value + "<br>";
}
document.getElementsByTagName("demo").innerHTML = text;
}
Right now the js file is returning and displaying data into the url instead of the page
I want to print text from input tag into js file and print it back into <p id="demo"></p>
here's my CSS code also
body{
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: black;
}
body span{
font-size: 4rem;
margin-top: 10rem;
color: rgb(255, 123, 123);
}
body span span{
color: rgb(220, 248, 96);
}
div{
display: flex;
align-items: center;
flex-direction: column;
color: rgb(255, 255, 255);
}
form{
display: flex;
flex-direction: column;
align-items: center;
}
#input-string{
background-color: white;
opacity: 1;
width: 20rem;
height: 3rem;
font-size: large;
}
#submit{
width: 4rem;
height: 1.2rem;
}
#output{
color: aliceblue;
}
textin<p id="demo"></p>?