/    Sign up×
Community /Pin to ProfileBookmark

please help

Basicly i need to create a page, where a popup at the start asks for student name, subject and then mark (all 3 seperate)

this is then displayed in a table , though a 4th column which using the if statement will display weather they pass or fail (50 is a pass, less is a fail)

now i have something pretty similar along the lines for what i need that i can modify (i know all i need to do is switch a few lines around)

<html>
<head>
<title>Total Price</title>
<script type=”text/javascript”>
var count=0, itemDescription, price;
var sum=0, avg;

itemDescription=prompt(“Input the item type quit to end”,””);
document.writeln(
“<table border = “1” width = “100%”>” );
document.writeln(
“<caption>Calculating Total Price of Items</caption>” );
document.writeln(
“<thead><tr><th align = “left”>Index</th>” );
document.writeln(
“<th align = “left”>Item description</th>” );
document.writeln(
“<th align = “left”>Price</th>” );

while(itemDescription!=”quit”)
{
count++;
price=prompt(“Input the price eg 2.45″,””);
price=parseFloat(price);
sum+=price;

document.writeln(
“<tr><td>”+count+”</td><td>”+itemDescription+”</td><td>”+price+”</td></tr>”);
itemDescription=prompt(“Input the Item Description type quit to finish”,””);
}
avg=sum/count;
document.writeln(“<tr><td>The Total price is</td><td></td><td>”+sum+”</td></tr>”);

document.writeln(“<tr><td>The average is</td><td></td><td>”+avg+”</td></tr>”);
document.writeln(“</table>”);

</script>
<link href=”cssFile.css” rel=”stylesheet” type=”text/css”>
</head>
<body>

</body>
</html>

thanks in advance (this has really got me stumped)

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JMRKEROct 21.2006 — Here's some code I modified from what you posted.
[code=php]
<html>
<head>
<title>Total Grades</title>
<script type="text/javascript">
var count=0, itemDescription, price;
var sum=0, avg;

itemDescription=prompt("Input the Course name (type quit to end)","");
document.writeln("<table border = "1" width = "100%">" );
document.writeln("<caption>Calculating Grades</caption>" );
document.writeln("<thead><tr><th align = "left">Name</th>" );
document.writeln("<th align = "left">Course</th>" );
document.writeln("<th align = "left">Grade</th>");
document.writeln("<th align= "left">Pass/Fail</th>");
document.writeln("</tr>");

while(itemDescription!="quit") {
count++;
price=prompt("Input the Grade (eg 100.00)","");
price=Number(price);
sum+=price;

document.writeln("<tr><td>"+count+"</td><td>"+itemDescription+"</td><td>"+price+"</td>");
if (price < 50) { document.writeln("<td>FAIL</td>") } else { document.writeln("<td>PASS</td") }
document.writeln("</tr>");
itemDescription=prompt("Input the Course name (type quit to finish)","");
}
avg=sum/count;
document.writeln("<tr><td>The Total grade is</td><td></td><td>"+sum+"</td></tr>");
document.writeln("<tr><td>The average is</td><td></td><td>"+avg+"</td></tr>");
document.writeln("</table>");

</script>
<link href="cssFile.css" rel="stylesheet" type="text/css">
</head>
<body>

</body>
</html>
[/code]

Note, you have no input verify checks; ie, entering a letter in a numeric input will result in an error.

Also you have no method to back-up and fix mistakes, so type carefully.

Finally, I do not know what it will look like with your CSS selections.

There may be some other drawback to using this rather than a spreadsheet,

but it's your code so I hope it serves your purpose.

Good Luck!
×

Success!

Help @dalm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...