-5

I'm honestly just confused on what I should code for this project.

This is for a project I'm working on. Countless attempts I've tried just made me land back to the ground floor.

<!DOCTYPE html>
<html>
    <head>
        <title>Equation Solver</title>

            <style>
            /* CSS styles goes here */

            form {
                margin: auto; /* Centers the Form */
                position: center;
                text-align: center;
                border: 4px solid black;
                background:rgb(153, 102, 255);
                color: black;
                width: 300px;
                height: 100%;
                padding: 20px 68px;
                border-radius: 32px 
            }

            </style>

                <script>
                //JavaScript code goes here



                </script>
    </head>

        <body>

            <h1 align="center"> Solve the Equation </h1>

                <form align="center">
                    <b>Click Me For a Mathematic Equation.</b><br>
                        <button onclick="ClickMe();">Click Me</button>
                </form>

                <form align="center">
                    <b>Submit Your Answer</b><br>
                        <button onclick="Submit();">Submit</button>
                </form>

                <form align="center">
                    <b>Reset</b><br>
                        <button onclick="Reset();">Reset</button>
                </form>

<br><br>

        </body>

</html>

One Form should have a button that once clicking it, it will generate a random equation out of 3 saved equations (I'm going to try to write code for a quadratic equation

The Other Form should be where you submit your answer to the random equation that was generated from above. If your answer is correct to the random equation then the background turns green otherwise it turns red. (The second part, I can do on my own)

The Last Form basically reloads your website in the tab.

  • 9
    Where is the Javascript? The posted question does not appear to include [any attempt](https://idownvotedbecau.se/noattempt/) at all to solve the problem. StackOverflow expects you to [try to solve your own problem first](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users), as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into in a [MCVE]. For more information, please see [ask] and take the [tour]. – CertainPerformance Feb 19 '19 at 01:35
  • Please add your JavaScript code. – Jack Bashford Feb 19 '19 at 01:35

1 Answers1

-1

You just need to write your functions inside the script block (between <script> and </script>, replacing //JavaScript code goes herewith your code.

You have to define the three functions used in the onclick events of the buttons. ClickMe(), Submit() and Reset()

Defining functions in Javascript

Clickme should get a random element from an array

Maybe you'll need also some dom manipulation function to add the content of the equation somewhere

Submit() needs to get some input and compare it to the expected result, so you'll need some input fields on your submit form

Or you should prompt the user to input the answer

As you are checking the answer to be valid. You'll need to check evaluating the equation exposed and maybe you need eval but remember

eval is evil

Your Reset() function just needs to reload the page - How to reload a page using JavaScript

jmtalarn
  • 1,513
  • 1
  • 13
  • 16