Issue
When I test this code in a browser the prompts pop up just fine, but then there's nothing on the screen after filling them all out. Is there something I'm missing...?
<!DOCTYPE html>
<html>
<head>
<title>Mad Libs</title>
</head>
<body>
<div id="out"></div>
<script>
var properName = prompt("Enter a proper name");
var verb = prompt("Enter a verb (past tense)");
var verb2 = prompt("Enter a second verb (past tense)");
var adj = prompt("Enter an adjective");
var adj2 = prompt("Enter another adjective");
var out = "Roses are red. Violets are blue. <br/>";
out += properName + "left town without wearing a shoe. <br/>";
out += properName + " " + verb + "<br/>";
out += "And " + properName + " " + verb2 + "<br/>";
out += "But I am " + adj + " " + properName + "thought. <br/>";
out += "And kind of " + adj2 + " too!";
document.getElementByID('out').innerHTML = out;
</script>
</body>
</html>
Solution
document.getElementByID
should be document.getElementById
:
<!DOCTYPE html>
<html>
<head>
<title>Mad Libs</title>
</head>
<body>
<div id="out"></div>
<script>
var properName = prompt("Enter a proper name");
var verb = prompt("Enter a verb (past tense)");
var verb2 = prompt("Enter a second verb (past tense)");
var adj = prompt("Enter an adjective");
var adj2 = prompt("Enter another adjective");
var out = "Roses are red. Violets are blue. <br/>";
out += properName + "left town without wearing a shoe. <br/>";
out += properName + " " + verb + "<br/>";
out += "And " + properName + " " + verb2 + "<br/>";
out += "But I am " + adj + " " + properName + "thought. <br/>";
out += "And kind of " + adj2 + " too!";
document.getElementById('out').innerHTML = out;
</script>
</body>
</html>
Answered By - Spectric Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.