I’m starting to apply what I’ve learnt in the Basic JavaScript course, as title says I want to have a user type into an html textarea, store it into a var and return it back to him as simple as that, or for the least have the console display the var. I am rather stomp as how to get going though.
You can try the following code
<div id="input" >input calculation query </div>
<textarea id="text" ></textarea>
<button onclick="handelclick()">=</button><br>
<div id="output" ></div>
<script>
function handelclick(){
var value= document.getElementById('text').value ;
document.getElementById('output').innerHTML= "answer : "+value ;
}
</script>
Hi thank you for helping, doesn’t seem to run as I edited following code
https://jsfiddle.net/asafaq/93shd506/18/
Here is why it doesn’t work. First you need to include in your html page. Something is not up and running with JS viewbox down there.
<DOCTYPE html>
<html>
<head></head>
<div name="data-input">input calculation query </div>
<p></p>
<textarea id="input" rows="4" cols="10"></textarea>
<p></p>
<button onclick="report()">=</button><br>
<p></p>
<div id="output" name="data-output">answer:</div>
<script>
function report(){
document.getElementById('output').innerHTML=document.getElementById('input').value;
}
</script>
</html>
1 Like
Thank you issue solved.