Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When a button is clicked, takes text that a user has entered in an input box and

ID: 3607734 • Letter: W

Question

When a button is clicked, takes text that a user has entered in an input box and then places this text somewhere else on the webpage.

You first need to add the necessary HTML elements for the JS to reference (i.e. button and input)

This is what it is suppose to entail but I cannot arrange it correctly

<input type="text" size="50" id ="in"/>
id="user"
<button>
click to add content
x ="userPage()"
</button>

<script type ="text/javascript">


function userPage(){
var x;
x =document.getElementById("in").value
>


}

</script>

Explanation / Answer

<html>
<head>
<script type ="text/javascript">

function userPage()
{
var x;
x = document.getElementById("in").value;
document.getElementById("user").innerHTML=x;

}

</script>
<title>
Webpage
</title>
</head>
<body>
<input type="text" size="50" id ="in"/>
<p id="user"></p>
<button>click to add content</button>

</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote