Javascript Game for Kids

amardikian

New Member
I'm trying to make a game in javascript. I still have many issues in the code. The code is supposed to have 2 buttons; one for shuffling images dice and a button to check if the kid wrote the correct answer or not.
  • 2 buttons
  • 1 textbox
  • and a place to show the answer if it's correct or not
Here is my code.I don't know why when I put the source of document.getElementbyID("test") it shows nothing because I want every time I click on start a random image is selected.I would appreciate any help as I am still a beginner in javascript.\[code\] <head> <script type="text/javascript">function startf(){var images = []; index = 0;images[0] = "<img src='http://stackoverflow.com/questions/14034426/1.png' length=70px width=75px>";images[1] = "<img src='http://stackoverflow.com/questions/14034426/2.png' length=70px width=75px>";images[2] = "<img src='http://stackoverflow.com/questions/14034426/3.png' length=70px width=75px>";images[3] = "<img src='http://stackoverflow.com/questions/14034426/4.png' length=70px width=75px>";index = Math.floor(Math.random() * images.length);take(index);function take(ind){return document.getElementbyId("ind")="What should i put here";}}function check(){var ch=getElementbyId("answer").value;if (ch=index+1){document.getElementbyId.innerHTML="TRUE";}else{document.getElementbyId.innerHTML="False";}}</script><br></head><img id="test" src="" alt="..." length="75px" width="75px" /><body><input type="button" value="http://stackoverflow.com/questions/14034426/start" onclick="startf()"><input id="answer" type="text" name="checkvalue" value="http://stackoverflow.com/questions/14034426/Enter Value" onclick="check()"><div id="fa"></div><input type="button" value=http://stackoverflow.com/questions/14034426/chek onclick="check()"></body>\[/code\]
 
Back
Top