Rh0ads
Mar 21st, 2001, 04:22 PM
How do i generate a random numnber (a 1 or a 0) in javascript and then play a sound if the number is a 1?
Mark Sreeves
Mar 22nd, 2001, 05:13 AM
One staep at a time please! ;)
Here's the code for a random 0 or 1...
<html>
<SCRIPT LANGUAGE="JavaScript">
function z() {
var x = Math.floor(Math.random() * 2)
document.frm1.Text1.value= x
if(x==1)
{
alert("Code to play sound required here!")
}
}
</script>
</html>
<body>
<FORM NAME="frm1">
<INPUT NAME="Text1" VALUE="" SIZE="3"><BR>
<INPUT TYPE="BUTTON" onClick="z();" value="Click"><BR>
</FORM>
</body>
</html>