# JavaScript submit button

**URL:** <https://forum.kirupa.com/t/javascript-submit-button/328734>\
**Category:** web dev\
**Created:** [June 11, 2012, 5:36pm UTC](https://forum.kirupa.com/t/javascript-submit-button/328734 "2012-06-11T17:36:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GAFAAAAA](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@GAFAAAAA](https://forum.kirupa.com/u/GAFAAAAA)\
**Post date:** [June 11, 2012, 5:36pm UTC](https://forum.kirupa.com/t/javascript-submit-button/328734/1 "2012-06-11T17:36:02Z")

</div>

Hi,

Its nice to be back!!! Anyway I’ve recently started moving into JavaScript and I’ve made a simple game to get me started. It gives you three numbers of a sequence and you work out the fourth (it’s for kids) when you get it right it said “right” and vice versa.

\*\*All I need help with is the answer input. I realize you need a form box, but the submit script and the rest is a bit of a mystery to me. I know I will need an if statement somewhere saying if the answer they give is equal to the answer I give, say “true”.

\*\*My code so far;

```auto

<body>
<script type="text/javascript">
var a;
var b;
var c;
var ans;
var ran;

ran=Math.floor(Math.random()*11);
a=Math.floor(Math.random()*11);
b=a+ran
c=b+ran
ans=c+ran

document.write(a);
document.write("<br>");
document.write(b);
document.write("<br>");
document.write(c);
document.write("<br>");
document.write("<button onClick='{alert(ans);}'>cheat</button>");
</script>
</body>

```
