WEB Can you guys help me with some basic javascript real fast?

Discussion in 'OT Technology' started by Kirk Hinrich, May 18, 2008.

  1. Kirk Hinrich

    Kirk Hinrich New Member

    Joined:
    Sep 20, 2004
    Messages:
    40,492
    Likes Received:
    0
    Location:
    Brown Line
    I'm just learning javascript, this is our first homework assignment. Anyway, I'm supposed to be making a little operation that averages grades. Ive got it all set, except that the numbers all display in a line. How do I seperate them out into paragraphs? Here is my code, tahnks.

    <html>
    <head>
    <title> Finding Grade Averages</title>
    </head>
    <body style="background:darkgreen">
    <h2 style="color:maroon;font-family:verdana">Finding Grade Averages</h2>
    <script type="text/javascript">
    var homework, lab, mid, finals;
    homework= prompt("Enter your homework average","");
    lab= prompt("Enter your lab average","");
    mid= prompt("Enter your midterm score","");
    finals= prompt("Enter your final score","");
    average= homework*0.25 + lab*0.20 + mid*0.25 + finals*0.30;
    document.write("your homework average is" + homework);
    document.write("your lab average is"+ lab);
    document.write("your midterm score is" + mid );
    document.write("your final exam score is " + finals);
    document.write("your average is" +average);
    </script>
    </body>
    </html>
     
  2. littleman

    littleman I took an AMEX survey and all I got was this crapp

    Joined:
    Sep 9, 2004
    Messages:
    2,597
    Likes Received:
    0
    Location:
    NY
    You'll want to add the <p>'s in the document.write

    Code:
    <html>
    <head>
    <title> Finding Grade Averages</title>
    </head>
    <body style="background:darkgreen">
    <h2 style="color:maroon;font-family:verdana">Finding Grade Averages</h2>
    <script type="text/javascript">
    var homework, lab, mid, finals;
    homework= prompt("Enter your homework average","");
    lab= prompt("Enter your lab average","");
    mid= prompt("Enter your midterm score","");
    finals= prompt("Enter your final score","");
    average= homework*0.25 + lab*0.20 + mid*0.25 + finals*0.30;
    document.write("<p>your homework average is " + homework + "</p>");
    document.write("<p>your lab average is "+ lab + "</p>");
    document.write("<p>your midterm score is " + mid + "</p>");
    document.write("<p>your final exam score is " + finals + "</p>");
    document.write("<p>your average is " +average + "</p>");
    </script>
    </body>
    </html>
     
  3. Kirk Hinrich

    Kirk Hinrich New Member

    Joined:
    Sep 20, 2004
    Messages:
    40,492
    Likes Received:
    0
    Location:
    Brown Line
    :uh: thanks. I was trying that but forgot to have em in the quotes.
     

Share This Page