-3

I am trying to develop a simple online word game using Javascript. I'm have way through, but I'm stuck at the moment. Basically the first part of the game is to display ten words and it's description.

Then users can click the "test me" button and will be directed to a page I called testme.html where I will show a description, and then, four words they could choose from. I have the description working fine once a player clicks the button the next description appears. Now, I need to be able to switch around the multiple choices as well, and also create a function where I could see if they picked the right or wrong word and then at the end I could display how many they got right or wrong for example: you got 9/10 right.

Here is the main page: http://alexallin.com/wordgame/

Here is the testme.html page: http://alexallin.com/wordgame/Testme.html

var ThisText = 0;

var Words = [ { word: '1. Amicable', definition: 'friendly, agreeable.' }, 
              { word: '2. acumen', definition: 'the ability to make good judgments and quick decisions, typically in a particular domain.' }, 
              { word: '3. accoutrements', definition: 'additional items of dress or equipment, or other items carried or worn by a person or used for a particular activity.' },
              { word: '4. Abstinence', definition: 'the act of refraining from pleasurable activity, e.g., eating or drinking.' },
              { word: '5. Adulation', definition: 'high praise.' },
              { word: '6. Adversity', definition: 'misfortune, an unfavorable turn of events.' },
              { word: '7. Aesthetic', definition: 'pertaining to beauty or the arts.' },
              { word: '8. Anachronistic', definition: 'out-of-date, not attributed to the correct historical period.' },
              { word: '9. Anecdote', definition: 'short, usually funny account of an event.' },
              { word: '10. Antagonist', definition: 'foe, opponent, adversary.' },
];


function ChangeWordTo(NextWord) { 

    document.getElementById('Answer_Box_One').innerHTML = NextWord;

}
 // this grabs the ID description
function ChangeDescriptionTo(NextDescription) {

    document.getElementById('description').innerHTML = NextDescription;

}

// This loads it to the first definition...
function onLoad() {
      switchTo(0);
}

// won't work with out
function switchTo(which) {
     ChangeWordTo(Words[which].word);
     ChangeDescriptionTo(Words[which].definition);
}

// This increments as button is click
function ShowDesc() {
    ThisText++;
    switchTo(ThisText);

}

Here is the HTML code------------------------

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css">
<script src="score.js"></script>

</head>
<body onload="onLoad();">

<div id="main">
  <div>
     <center><p id="description">Read the Discription and chose your answer below.</p></center>
  </div>

<br/>

<!--
 <div id="Answer_Box">
 <center>
   <form>
        <input type="checkbox" name="vehicle" value="text" id="Answer_Box_One">I have a bike 

   </form> 
-->

<form>
<center>
<div style="float: left; width: 50%;">
<ul>

  <label id="Answer_Box_One" for="male">Male</label>
  <input type="radio" name="sex" id="male" value="male"><br>

  <label id="Answer_Box_Two" for="male">Female</label>
  <input type="radio" name="sex" id="male" value="Female"><br>

  </ul>
</div>

<div style="float: right; width: 50%;">
<ul>

    <label id="Answer_Box_Three" for="male">Male</label>
  <input type="radio" name="sex" id="male" value="male"><br>

  <label id="Answer_Box_Four" for="Not Above">Not Above</label>
  <input type="radio" name="sex" id="Not Above" value="Not Above"><br>

</ul>
</div>  
  <button type="button" onclick="ShowDesc();">Correct</button>

</center>
</form>



</center>
</div>



</div>
</body>
</html>
Alex Knows
  • 11
  • 2
  • 8
  • 3
    Uh... so you want us to... build your program? I don't see any relevant code here for **test me**, **switch around the multiple choices**, **picked the right or wrong word**, or **you got 9/10 right**. That's a lot of questions bud. – Nicholas Hazel Jan 29 '14 at 04:38
  • cant understand your game... you are showing both the words and description then what do you test for? and why aren't you using global variables to maintain scores ... – Saurabh Jan 29 '14 at 04:44
  • This is mostly for practice. Once I get it to work I would switch the description to a sentence with a fill in the blank type of question like so ( what is 1+1=_________.). Yes, I'm completely stuck, I'm not asking for someone to write the program for me, but someone to please guide me on how to complete this task. I been working on it for a while. I can't figure it out on my own, I need help. Thanks @Saurabh – Alex Knows Jan 29 '14 at 04:50
  • Please see Stack Overflow Help on what is considered [on-topic](http://stackoverflow.com/help/on-topic), particularly noting point #3 and #4. Also, your question is too broad: What is your specific problem? If you don't know how to sample from an array, ask that. Or better yet, see if anyone has asked it before (for example, http://stackoverflow.com/questions/11935175/sampling-a-random-subset-from-an-array). On the other hand, "how do I write this game?" is much, much too broad a question. – Amadan Jan 29 '14 at 05:03
  • If you look I've got pretty far on my own. Now, I'm stuck. I just need to know how can I verify a user picked the right choice, and store that somewhere, and I'm confuse on how to switch all four multiple choices around. @Amadan – Alex Knows Jan 29 '14 at 05:15

1 Answers1

1

Hey i am just helping because i think u r really stuck. But later please take care about what you ask and please be specific.

Your html was a bit messed so i had to change it (talking mainly about the options section cause it is the main part of your game)

now for your game let me tell you this .

  1. <input type='radio'> should have value the same as the label that you are displaying,cause it will help you for checking for correct answer.
  2. you have to dynamically load the options (in demo i have shown how to do it for one for rest please figure it out)
  3. read a bit about jquery,javascript and html before you start working on this one again.

now the i have used jquery and i suggest u also use it as later on it will be of great help to you and if you know javascript then jquery would be a easy job for u.(trust me on this one).

This is the demo for your game

Saurabh
  • 1,007
  • 2
  • 10
  • 24
  • Thank you so much. I've been studying the basic of javascript, but I see I need to go over it again and again till I get it down pack. – Alex Knows Jan 29 '14 at 15:13