if statement after innerhtml?

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 2994 Views - Last Post: 05 December 2012 - 02:54 PM

#1 woodsmc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 04-October 12

if statement after innerhtml?

Posted 04 December 2012 - 11:05 PM

function GetAverage()
    {homework=parseFloat(document.getElementById('homeworkBox').value);
    labs=parseFloat(document.getElementById('labsBox').value);
    midterm=parseFloat(document.getElementById('midtermBox').value);
    exam=parseFloat(document.getElementById('examBox').value);
    
    average = (homework *.25) + (labs *.20) + (midterm * .25) + (exam*.30)
    document.getElementById('outputdiv') .innerHTML='Your Course Average=' + average
     if (grade< 60) {letterGrade='F';}
     }
    

Everything works fine but im trying to get it to say something like your letter grade is F or A ext below your course average any ideas on what im doing wrong.?
Would appreciate any help

Is This A Good Question/Topic? 0
  • +

Replies To: if statement after innerhtml?

#2 Coding123  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 26-November 12

Re: if statement after innerhtml?

Posted 05 December 2012 - 04:00 AM

Well you could write a couple of if statements so you could get different grade output. Perhaps you could write what exactly does not work in your case?
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: if statement after innerhtml?

Posted 05 December 2012 - 04:14 AM

hint: and you would do that before the innerHTML assignment.
Was This Post Helpful? 1
  • +
  • -

#4 woodsmc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 04-October 12

Re: if statement after innerhtml?

Posted 05 December 2012 - 06:33 AM

I still cant get it to work do I need to alter the inner html statement I feel I would need to but im not assigning another variable It's based on a condition.
And I moved the if statement to multiple different places and still am having no luck.
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: if statement after innerhtml?

Posted 05 December 2012 - 06:37 AM

do you want the average or the grade (based on the average) to be displayed?
Was This Post Helpful? 0
  • +
  • -

#6 woodsmc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 04-October 12

Re: if statement after innerhtml?

Posted 05 December 2012 - 06:44 AM

I already have the average being displayed I am trying to have a letter grade displayed also based on the average inputted.
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: if statement after innerhtml?

Posted 05 December 2012 - 06:45 AM

is the grade to be displayed somewhere else or in the same element?
Was This Post Helpful? 0
  • +
  • -

#8 woodsmc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 04-October 12

Re: if statement after innerhtml?

Posted 05 December 2012 - 06:47 AM

They are both to be displayed in the same element I assume that would be the way to do it if you wanted it in the same place.
Was This Post Helpful? 0
  • +
  • -

#9 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: if statement after innerhtml?

Posted 05 December 2012 - 06:48 AM

you could do for instance elem.innerHTML = average + "/" + grade;
Was This Post Helpful? 0
  • +
  • -

#10 woodsmc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 04-October 12

Re: if statement after innerhtml?

Posted 05 December 2012 - 06:55 AM

What is supposed to be there the if statement or something else? I got the impression from your earlier post my if statement needed to be somewhere else.
Was This Post Helpful? 0
  • +
  • -

#11 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: if statement after innerhtml?

Posted 05 December 2012 - 07:01 AM

the if() statements would be useful to calculate the grade from the average.
Was This Post Helpful? 0
  • +
  • -

#12 woodsmc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 04-October 12

Re: if statement after innerhtml?

Posted 05 December 2012 - 07:04 AM

I understand that I was wondering what you were implying went between the ""
Was This Post Helpful? 0
  • +
  • -

#13 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: if statement after innerhtml?

Posted 05 December 2012 - 07:05 AM

???
Was This Post Helpful? 0
  • +
  • -

#14 woodsmc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 04-October 12

Re: if statement after innerhtml?

Posted 05 December 2012 - 07:08 AM

elem.innerHTML = average + "/" + grade; what goes inbetween the "/" nothing I am trying is working
Was This Post Helpful? 0
  • +
  • -

#15 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: if statement after innerhtml?

Posted 05 December 2012 - 07:14 AM

suppose we have an average of 60 and that were a grade of F, average + "/" + grade would become 60/F in the output. of course you can use any other strings inbetween those two values.

and average and grade are the variables holding those values.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2