Hey, I’m new to using Javascript/html and I’m trying to make an 8-ball program to try and learn the basics. Here’s the code:
<!doctype html>
<html>
<head>
<script type="text/javascript" src="http://balance3e.com/random.js"></script>
<script type="text/javascript">
function DisplayMessage()
//assumes:
//results:
{
var answer;
answer=RandomOneOf(["Absolutely", "Phenomenaly", "Without a doubt not", "As possible as a snowball's chance in hell", "Perchance yes, perchance no"]);
document.getElementById('outputDiv').innerHTML='The Wizard says: <i> ' +answer+ ' </i>';
}
</script>
<title>Ask the Wizard</title>
</head>
<body>
Ask a question, then click the 8-ball to ask the Wizard your question!
<input type="text"><br>
<img src=8ball.gif
onclick=
<div id="outputDiv"></div>
</body>
</html>
Here are my 2 questions:
- How do I connect RandomOneOf and the output?
- Which of the get functions do I use for the onclick event?
Like I said, absolute beginner in Javascript. Any help would be appreciated.