SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help with javascript math game

    I'm building a javascript math game for a web site.
    Its all working fine.
    im using document.get element by id to populate 2 divs with randomly generated numbers.
    the user enteres the answer into a textbox
    clicks check answer button and a message box displays letting the user know if the answer was right or wrong.

    THIS NEXT PART IS WHERE IM HAVING TROUBLE

    After the user clicks check answer button i want the sidebar to populate with all the answered sums so after 3 sums it will look like this:

    num1 + num2 = ans
    num1 + num2 = ans
    num1 + num2 = ans

    Any help would be greatly appreciated.
    thanks

    This is driving me nuts.

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    266
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    If you add the answers for example into a DIV with id="iddiv", try something like this in your js code, to append the answers:
    Code:
    document.getElementById('iddiv').innerHTML += '<br/>'+ num1 +'+'+ num2 +'= '+ ans;
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •