hi there,
im trying to create a simple guessing game which uses functions and buttons. the computer is to create a random number in between two user set limits from the text boxes in the form. that is the role of one function. the second function will process the guesses, ask user for guesses. the game will essentially go on and on until the user says cancel in the confirm box. the third function will only relate the play button with the play function. this is what i have so far.
<body>
<form action=”” method=”post”>
<h1>Guessing Game</h1>
<p>Lower Limit:
<input type=”text” id=”lowerLimit” value=”1″ /><br /><br />
</p>
<p>Upper Limit:
<input type=”text” id=”upperLimit” value=”3″ /><br /><br />
</p>
<p>
<input type=”button” id=”PlayGame” value=”Play Game” onclick= “playGame()” />
</p>
<p>
<input type=”reset” id=”ResetValues” value=”Reset Values” />
</p>
</form>
<script type=”text/javascript”>
/*<![CDATA[*/
/* calling main */
main();
function getRandomValue(lowerLimit, upperLimit) {
document.getElementById(lowerLimit).value;
document.getElementById(upperLimit).value;
var randomNumber = Math.floor((upperLimit – lowerLimit + 1) * Math.random() + lowerLimit);
return randomNumber;
}
function playGame() {
randomNumber;
var guess = Number(prompt(“guess number”));
}
function main() {
/* Where we call the other functions */
playGame()
}
/*]]>*/
</script>
</body>