Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Probably already answered: got a die/dice, want to display button depending on result

$
0
0
This is what I got, a friend helped me out so button could only be pressed once, I actually have no clue on html
Spoiler:
<!DOCTYPE html>
<html>
<body>
<h1 ALIGN=center>
<button id="boton" onclick="myFunction()">Try to hit</button>
<h2 ALIGN=center id="demo"></p ALIGN=center>
<script>
function myFunction() {
document.getElementById("boton").disabled = true;
var x = Math.floor((Math.random() * 20) + 1);
document.getElementById("demo").innerHTML =x;
if ( x <= 5 ) {
document.getElementById("demo").innerHTML += "<p>You fail your attack";
} else {
document.getElementById("demo").innerHTML += "<p>You hit";
}
}
</script>
</h1 ALIGN=center>
</body>
</html>
the text was something different but this is just fine for you guys to understand what I want to do :P
I tried replacing "You fail your attack" with "[[You fail your attack|Fail ]] but, as you can conclude, no result

It would be awesome too to keep the random number hidden, and yes, I know there are better ways to do this but, those were too hard for me, sorry.

So, if anyone is willing to kindly help me, thanks in advance :D

Viewing all articles
Browse latest Browse all 1844

Trending Articles