In an X/HTML form, which script block will retrieve an input value and display it back without errors
or warnings?
A.
<script type=”text/javascript”>
function ShowEntry() {
var inp = document.getElementById(“i”);
var s = inp.value;
B.
value = s; }
</script>
<input id=”i” onchange=”ShowEntry()” />
You entered: <span id=”d”></span>
C.
<script type=”text/javascript”>
function ShowEntry() {
document.getElementById(“i”);
var s = i.innerHTML;
document.getElementsByName(“d”).innerHTML = s; }
</script>
<input id=”i” onchange=”ShowEntry()” />
You entered: <span id=”d”></span>
D.
<script type=”text/javascript”>
function ShowEntry() {
var inp = document.getElementById(“i”);
var s = inp.value;
document.getElementsbyName(“d”).innerHTML = s; }
</script>
<input id=”inp” onchange=”ShowEntry()” />
You entered: <span id=”d”></span>
E.
<script type=”text/javascript”>
function ShowEntry() {
var inp = document.getElementById(“i”);
var s = inp.value;
document.getElementById(“d”).innerHTML = s; }
</script>
<input id=”i” onchange=”ShowEntry()” />
You entered: <span id=”d”></span>
Explanation:
“Show Answer” not working on this page
Answer E is the only one that works by displaying the text entered and doesn’t error. Tested in Chrome.
E is the correct answer