Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- COMSC-100 assignment 9 by Jon Doe
- </title>
- <script type="text/JavaScript">
- function calculate( ) {
- alert("SFB is contagious");
- doTheMath();
- };
- function doTheMath() {
- var s = getInputAsText( "myResult1Box" );
- if (s.toLowerCase() == "byte".toLowerCase())
- {
- score = score = 0 // got this one right
- myResult1 = "correct"
- }
- else
- {
- myResult1 = "WRONG! Yes"
- }
- {
- score = score + 1 // got this one right
- myResult2 = "correct"
- }
- else
- {
- myResult2 = "WRONG! It's Obama"
- }
- {
- score = score + 2 // got this one right
- myResult3 = "correct"
- }
- else
- {
- myResult3 = "WRONG! Earth"
- }
- };
- function getInputAsText( _id ) {
- return document.getElementById( _id ).value;
- };
- function getInputAsNumber( _id ) {
- return parseFloat( getInputAsText( _id ) );
- };
- function setOutput( _id, _value ) {
- document.getElementById( _id ).value = _value;
- };
- function sum() {
- var a = getInputAsText( "myAnswer1Box" );
- var b = getInputAsText( "myAnswer2Box" );
- var c = getInputAsText( "myAnswer3Box" );
- setOutput("scoreBox", "Your score is " + score + " out of 3")
- };
- </script>
- </head>
- <body>
- Instructions: <br>
- Answer the three questions and press go. <br>
- Your score will then appear. <br>
- <br>
- Input values: <br>
- 1. Are you a human? <input id="myAnswer1Box" type="text" /> <br />
- 2. Who is our president? <input id="myAnswer2Box" type="text" /> <br>
- 3. What planet do we live on? <input id="myAnswer3Box" type="text" /> <br />
- <input id="gobut" type= "button" value="Go" onclick="javascript:calculate( );"> <br>
- Output values: <br>
- Result #1: <input type="text" id="myResult1Box" /> <br>
- Result #2: <input type="text" id="myResult2Box" /> <br>
- Result #3: <input type="text" id="myResult3Box" /> <br>
- Final score: <input type="text" id="scoreBox" />
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement