Kockagame:
<head> <Script language="JavaScript"> function dobo() { var gep, gepp, emb, embp, tet, nyert; gep=parseFloat(document.fo.gep.value) gepp=parseFloat(document.fo.gepp.value) emb=parseFloat(document.fo.emb.value) embp=parseFloat(document.fo.embp.value) tet=parseFloat(document.fo.tet.value) if (tet<=embp && tet<=gepp) {gep=Math.round (Math.random()*5+1) document.fo.gep.value=gep emb=Math.round (Math.random()*5+1) document.fo.emb.value=emb if (gep>emb) { document.fo.nyer.value="Nem nyert" gepp=gepp+tet document.fo.gepp.value=gepp embp=embp-tet document.fo.embp.value=embp } if (gep<emb) { document.fo.nyer.value="nyertl" gepp=gepp-tet document.fo.gepp.value=gepp embp=embp+tet document.fo.embp.value=embp } if (gep==emb) { document.fo.nyer.value="Dntetlen" }} else {alert("Tl nagy a tted!")} } </Script> </head> <body> <form name="fo"> Gp dobsa: <input name="gep" disabled value=0> Gp pnze: <input name="gepp" disabled value=10><br> Tted<input name="tet" value=5><br> Te dobsod: <input name="emb" disabled value=0> Te pnzed: <input name="embp" disabled value=10><br> <button onclick="dobo()"> Dobok </button><br> <input name="nyer"><br> </form> </body>
|