I want to create a sheet where there is a few math problems.
Example:
1+1 or 2+4.
And then below it is a box to fill in. You fill in the box and it pops up with a correct or wrong error.

At the end, I would need to show the entire page with all of the answers.
I also need a place where they can carry over the number. for example if it were 19+35.
How do I do this?
I need to do it in JavaScript.

Thanks!

Member Avatar for stbuchok

I also need a place where they can carry over the number

What do you mean by this?

Also, can you please post the code you are having trouble with. We aren't going to write this for you, but we are willing to help if you show that you've actually tried to work it out.

Below is what I have so far. I don't want people to write it for me, just want some direction. I want to be able to learn this stuff!

These are the requirements. I'm not sure how to do the one at a time thing.
You must deliver the problems one at a time.
You must make use of pop-up windows or iframes.
provide the students with a place to write the carry over
The problem should grade itself and return feedback to the students (if it's correct, give them some positive feedback; if it's incorrect, give some indication that it's incorrect and give the right answer).
When the student has completed all of the problems, you will show them a single page with all the problems with the student's answers.
The numbers should range from 1 - 50. Each number the student can add must be less than or equal to 50. The maximum answer will then be 100.

<!DOCTYPE html>
      <html>
      <head>
      <title>Math Worksheet</title>
      <script type="text/javascript">

    
//Write the getAnswer() function
      function getoneAnswer()
      {
      var userAnswer = document.getElementById('txtOne').value;
        var secretName = "2";
       
	    if( userAnswer == 2 ) {
      alert( "Correctomundo!" );
}
        else if( userAnswer == 1)
      {
      alert("Almost!");
      }   
         else
      {
      alert("Bummer!");
      }
//the getoneAnswer() function ends here
      }
	  
	  
	  
        </script>
      </head>
      <body>
      <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">Math Worksheet</p>
      
      <p>1+1=      
      <input type="text" id="txtOne" size="2"/>
      <input type="button" value="Go" id="btnoneAnswer" onclick="getoneAnswer()"/></p>

      
      </body>
      </html>

I have been working on simplifying it. Here is what I have. For some reason I can't get the txt box to work correctly. Any thoughts?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


<p>1+1= <input id="prob1" size="4" type="text" onclick="Problem1()"/></p>

<script>
function Problem1() //must have () with a function. these are opening and closing parentheses. 
{ // this tells where function starts
var AnswerOne;
AnswerOne = document.getElementById('prob1').value; //this gets the code from the textbox that the person inputs
if (AnswerOne.value = 2) 
{
	alert("Yep");
}
else {
	alert("Nope");
}
} //this tells where function ends
</script>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.