Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I'm having trouble w/ this html

    Hello, I'm taking a COM Science class now, and this assignment really
    make me mad

    PHP Code:
    <html>
      <
    head>
        <
    title>
          
    COMSC100-1242 Assign 9 by Petit 1339071
        
    </title>

        <
    script>
             
    // these functions set the variable type, location, and use the setOutput code
             
    function getInputAsText(_id){return document.getElementById(_id).value}
             function 
    getInputAsNumber(_id){return parseFloat(document.getElementById(_id).value)}
             function 
    setOutput(_id_value){document.getElementById(_id).value _value}


             
    //this function is ran when the button is clicked
             
    function calculate()
                {
                 
    // declare all variables
                 
    var myAnswer1
                 
    var myAnswer2
                 
    var myAnswer3
                 
    var Score 0
                 
    var myResult1
                 
    var myResult2
                 
    var myResult3
                              
                 
    // get input values
                 
    myAnswer1 getInputAsText("myAnswer1Box")
                 
    myAnswer2 getInputAsText("myAnswer2Box")
                 
    myAnswer3 getInputAsText("myAnswer3Box")
                 
    myResult1 getInputAsText("myResult1Box")
                 
    myResult2 getInputAsText("myResult2Box")
                 
    myResult3 getInputAsText("myResult3Box")
                 
    score getInputAsText("scoreBox")
                 
                 
    // perform concatenation
          
                 
    if (myAnswer1 == "8")
                 {
                  
    score score +// got this one right
                  
    myResult1 "correct"
                 
    }
                 else
                 {
                  
    myResult1 "WRONG! It's 8 bites"

                 
    if (myAnswer2.toLowerCase() == "Apple".toLowerCase())
                 {
                  
    score score +// got this one right
                  
    myResult2 "correct"
                 
    }
                 else
                 {
                  
    myResult2 "WRONG! It's Apple"
                 
    }

                 if (
    myAnswer3.toLowerCase() == "Microsoft".toLowerCase())
                 {
                  
    score score +// got this one right
                  
    myResult3 "correct"
                 
    }
                 else
                 {
                  
    myResult3 "WRONG! It's Microsoft"
                 
    }
                  
                 
    // write output value
                 
    setOutput("myResult1Box"myResult1)
                 
    setOutput("myResult2Box"myResult2)
                 
    setOutpup("myResult3Box"myResult3)
                 
    setOutput("scoreBox" "Your score is " score " out of 3")
              
                }
        
    </script>
      </head>

      <body>
                <!type instructions to a user>
                 Instructions:<br>
                 Answer the three questions and press go. <br>
                 Your score will appear.<br>
                 <br>
                 Input values: <br>
                 1. A byte is how many bits? <input id ="myAnswer1Box"><br>
                 2. Steve Jobs heads what company? <input id ="myAnswer2Box"><br>
                 3. Bill Gates heads what company? <input id ="myAnswer3Box"><br>
                 <input type="submit" value="go" onclick="calculate()"><br>

                 <br>
                 Output value: <br>
                 Result #1: <input id = "myResult1Box" size="50"><br>
                 Result #2: <input id = "myResult2Box" size="50"><br>
                 Result #3: <input id = "myResult3Box" size="50"><br>
                 Your score: <input id = "scoreBox" size="50"><br>
      </body>
    </html> 
    There might be 3 boxes for writing answers, other 3 boxes for showing results, and another box for the total score.

    I tried validator and did google search, but it was not so helpful.

    Could you help me for this assignment? T-T(crying)

  • #2
    New Coder
    Join Date
    Dec 2012
    Location
    Ingerlund
    Posts
    66
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Code below
    Last edited by Entity_; 04-29-2013 at 01:36 PM.

  • #3
    New Coder
    Join Date
    Dec 2012
    Location
    Ingerlund
    Posts
    66
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Code:
    <html> 
      <head> 
        <title> 
          COMSC100-1242 Assign 9 by Petit / 1339071 
        </title> 
    
        <script> 
             // these functions set the variable type, location, and use the setOutput code 
             function getInputAsText(_id){return document.getElementById(_id).value} 
             function getInputAsNumber(_id){return parseFloat(document.getElementById(_id).value)} 
             function setOutput(_id, _value){document.getElementById(_id).value = _value} 
    
    
             //this function is ran when the button is clicked 
             function calculate() 
                { 
                 // declare all variables 
                 var myAnswer1 
                 var myAnswer2 
                 var myAnswer3 
                 var Score = 0 
                 var myResult1 
                 var myResult2 
                 var myResult3 
                               
                 // get input values 
                 myAnswer1 = getInputAsNumber("myAnswer1Box") 
                 myAnswer2 = getInputAsText("myAnswer2Box") 
                 myAnswer3 = getInputAsText("myAnswer3Box") 
                 myResult1 = getInputAsText("myResult1Box") 
                 myResult2 = getInputAsText("myResult2Box") 
                 myResult3 = getInputAsText("myResult3Box") 
                 score = getInputAsText("scoreBox") 
                  
                 // perform concatenation 
           
                 if (myAnswer1 == "8") 
                 { 
                  Score+=1  // got this one right 
                  myResult1 = "correct" 
                 }
                 else 
                 { 
                  myResult1 = "WRONG! It's 8 bites"
    			 }			  
    			
                 if (myAnswer2.toLowerCase() == "Apple".toLowerCase()) 
                 { 
                  Score+=1 // got this one right 
                  myResult2 = "correct" 
                 } 
                 else 
                 { 
                  myResult2 = "WRONG! It's Apple" 
                 } 
    
                 if (myAnswer3.toLowerCase() == "Microsoft".toLowerCase()) 
                 { 
                  Score+=1  // got this one right 
                  myResult3 = "correct" 
                 } 
                 else 
                 { 
                  myResult3 = "WRONG! It's Microsoft" 
                 } 
                   
                 // write output value 
                 setOutput("myResult1Box", myResult1) 
                 setOutput("myResult2Box", myResult2) 
                 setOutput("myResult3Box", myResult3) 
                 setOutput("scoreBox" , "Your score is " + Score + " out of 3") 
               
                } 
    			
        </script> 
      </head> 
    
      <body> 
                <!type instructions to a user> 
                 Instructions:<br> 
                 Answer the three questions and press go. <br> 
                 Your score will appear.<br> 
                 <br> 
                 Input values: <br> 
                 1. A byte is how many bits? <input id ="myAnswer1Box"><br> 
                 2. Steve Jobs heads what company? <input id ="myAnswer2Box"><br> 
                 3. Bill Gates heads what company? <input id ="myAnswer3Box"><br> 
                 <input type="submit" value="go" onclick="calculate()"><br> 
    
                 <br> 
                 Output value: <br> 
                 Result #1: <input id = "myResult1Box" size="50"><br> 
                 Result #2: <input id = "myResult2Box" size="50"><br> 
                 Result #3: <input id = "myResult3Box" size="50"><br> 
                 Your score: <input id = "scoreBox" size="50"><br> 
      </body> 
    </html>
    Hey. Sorry couldn't look at it any futher, I had to do some stuff. This should now be right, it's all in the details. You just forgot a couple of things.

    Although the problem wasn't with the HTML, it was with the JavaScript, so maybe this should get moved
    Last edited by Entity_; 04-29-2013 at 01:45 PM. Reason: I give an edit reason for no man

  • #4
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thx a lot

    How did u do this one OMG

    Thanks really a lot!


  •  

    Posting Permissions

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