-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed javascript function in gpa.js and added that function into jo…
…bs.html
- Loading branch information
unknown
authored and
unknown
committed
Feb 3, 2014
1 parent
5027506
commit c16e6b2
Showing
2 changed files
with
90 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
function calculateGPA(){ | ||
var it_3153 = document.getElementById("3153").value; | ||
var it_3503 = document.getElementById("3503").value; | ||
var it_4153 = document.getElementById("4153").value; | ||
var it_3883 = document.getElementById("3883").value; | ||
var it_4323 = document.getElementById("4323").value; | ||
var grades = new Array(); | ||
|
||
grades[0] = document.getElementById("3153").value; //it_3153 | ||
grades[1] = document.getElementById("3503").value; //it_3503 | ||
grades[2] = document.getElementById("4153").value; //it_4153 | ||
grades[3] = document.getElementById("3883").value; //it_3883 | ||
grades[4] = document.getElementById("4323").value; //it_4323 | ||
|
||
var gpa = (it_3153+it_3503+it_4153+it_3883+it_4323)/5; | ||
for(var i = 0; i<grades.length;i++){ | ||
if(grades[i] === 'A' || grades[i] === 'a'){ | ||
grades[i] = 4; | ||
} else if(grades[i] === 'B' || grades[i] === 'b'){ | ||
grades[i] = 3; | ||
} else if(grades[i] === 'C' || grades[i] === 'c'){ | ||
grades[i] = 2; | ||
} else if(grades[i] === 'D' || grades[i] === 'd'){ | ||
grades[i] = 1; | ||
} else { | ||
grades[i] = 0; | ||
} | ||
} | ||
|
||
var gpa = 0; | ||
|
||
for(var i = 0; i<grades.length;i++){ | ||
gpa+=grades[i]; | ||
} | ||
|
||
gpa /= 5; | ||
|
||
var div = document.getElementByID('content'); | ||
|
||
if (gpa < 3.5){ | ||
$("body").append("<p>We're sorry. Please try again next year!</p>"); | ||
//$("body").append("<p>We're sorry. Please try again next year!</p>"); | ||
var content = document.createTextNode("<p>We're sorry. Please try again next year!</p>"); | ||
div.appendChild(content); | ||
} else { | ||
$("body").append("<p>Congratulations! Please send your resume to <a href=\"mailto:[email protected]\">Curtis White</a></p>"); | ||
//$("body").append("<p>Congratulations! Please send your resume to <a href=\"mailto:[email protected]\">Curtis White</a></p>"); | ||
var content = document.createTextNode("<p>Congratulations! Please send your resume to <a href=\"mailto:[email protected]\">Curtis White</a></p>"); | ||
div.appendChild(content); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,51 @@ <h1> | |
</div> | ||
|
||
<div class="content"> | ||
<script src="gpa.js"></script> | ||
<script> | ||
function calculateGPA(){ | ||
var grades = new Array(); | ||
|
||
grades[0] = document.getElementById("3153").value; //it_3153 | ||
grades[1] = document.getElementById("3503").value; //it_3503 | ||
grades[2] = document.getElementById("4153").value; //it_4153 | ||
grades[3] = document.getElementById("3883").value; //it_3883 | ||
grades[4] = document.getElementById("4323").value; //it_4323 | ||
|
||
for(var i = 0; i<grades.length;i++){ | ||
if(grades[i] === 'A' || grades[i] === 'a'){ | ||
grades[i] = 4; | ||
} else if(grades[i] === 'B' || grades[i] === 'b'){ | ||
grades[i] = 3; | ||
} else if(grades[i] === 'C' || grades[i] === 'c'){ | ||
grades[i] = 2; | ||
} else if(grades[i] === 'D' || grades[i] === 'd'){ | ||
grades[i] = 1; | ||
} else { | ||
grades[i] = 0; | ||
} | ||
} | ||
|
||
var gpa = 0; | ||
|
||
for(var i = 0; i<grades.length;i++){ | ||
gpa+=grades[i]; | ||
} | ||
|
||
gpa /= 5; | ||
|
||
var div = document.getElementByID('content'); | ||
|
||
if (gpa < 3.5){ | ||
//$("body").append("<p>We're sorry. Please try again next year!</p>"); | ||
var content = document.createTextNode("<p>We're sorry. Please try again next year!</p>"); | ||
div.appendChild(content); | ||
} else { | ||
//$("body").append("<p>Congratulations! Please send your resume to <a href=\"mailto:[email protected]\">Curtis White</a></p>"); | ||
var content = document.createTextNode("<p>Congratulations! Please send your resume to <a href=\"mailto:[email protected]\">Curtis White</a></p>"); | ||
div.appendChild(content); | ||
} | ||
} | ||
</script> | ||
<h2 align="center">For more information please fill out the form below and click submit</h2> | ||
|
||
<form action=""> | ||
|
@@ -45,40 +89,42 @@ <h2 align="center">For more information please fill out the form below and click | |
<input type="text" name="lname" size="30" /> | ||
</label> | ||
|
||
<br /> | ||
|
||
<label>Please Enter your grade for IT 3153: | ||
<input type="text" id="3153" name="IT_3153" size="30" /> | ||
<input type="text" id="3153" name="IT_3153" size="5" /> | ||
</label> | ||
|
||
<br /> | ||
|
||
<br /> | ||
|
||
<label>Please Enter your grade for IT 3503: | ||
<input type="text" id="3503" name="IT_3503" size="10" /> | ||
<input type="text" id="3503" name="IT_3503" size="5" /> | ||
</label> | ||
|
||
<br /> | ||
|
||
<label>Please Enter your grade for IT 4153: | ||
<input type="text" id="4153" name="IT_4153" size="75" /> | ||
<input type="text" id="4153" name="IT_4153" size="5" /> | ||
</label> | ||
|
||
<br /> | ||
|
||
<label>Please Enter your grade for IT 3883: | ||
<input type="text" id="3883" name="IT_3883" size="30" /> | ||
<input type="text" id="3883" name="IT_3883" size="5" /> | ||
</label> | ||
|
||
<br /> | ||
|
||
<label>Please Enter your grade for IT 4323: | ||
<input type="text" id="4323" name="IT_4323" size="30" /> | ||
<input type="text" id="4323" name="IT_4323" size="5" /> | ||
</label> | ||
|
||
<br /> | ||
|
||
<p> | ||
<input type="submit" value="Submit" /> | ||
<input type="submit" value="Submit" onclick="calculateGPA()"/> | ||
<input type="reset" value="Clear form" /> | ||
</p> | ||
</form> | ||
|