Ok this is the code to a magic 8 ball
the problem I’m have is that I can’t figure a way to make an alert come up everytime the same question is repeated.
any ideas would be greatly appreciated
<script type=”text/javascript” language=”javascript”>
function Answerquestion()
{
var response = new Array ()
response [0] = “Maybe”;
response [1] = “Yes”;
response [2] = “No”;
response [3] = “Yes, definately”;
response [4] = “Reply is hazy, please try again”;
response [5] = “It appears to be so”;
response [6] = “What is it you really want to know?”;
response [7] = “Outlook is good”;
response [8] = “My sources say no”;
response [9] = “Cannot predict now”;
response [10] = “Don’t count on it”;
response [11] = “Signs point to yes”;
response [12] = “As I see it, yes”;
response [13] = “Concentrate and ask again”;
response [14] = “Better not tell you now”;
var x = Math.random()* response.length;
x = Math.floor(x);
var question = txtQuestion.value
var lastChar = question.charAt(question.length – 1)
if (lastChar == ‘?’)
{ Answer.innerHTML=(response[x])
}
else
alert(“Please ask a question that ends with a ‘?'”)
{
txtQuestion.focus()
}
var newquestion = “txtQuestion.value”;
var oldquestion = question
if (newquestion = oldquestion)
{
alert(“Question Cannot repeat”)
}
}
</script>