Google Answers Logo
View Question
 
Q: Javascript/html question ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Javascript/html question
Category: Computers > Programming
Asked by: purplepit-ga
List Price: $30.00
Posted: 30 Mar 2003 13:27 PST
Expires: 29 Apr 2003 14:27 PDT
Question ID: 183315
Could you please help supply the code for the following....
I need to create the following..and the results need to be in a
table!!!!

Your page should have a form in which you can enter a student
registration number, a name, 6 tutorial marks, 1 coursework mark, and
one exam mark. The maximum marks and weighting are as follows: 
Maximum mark Weighting
Tutorial 1 3 3 
Tutorial 2 3 3 
Tutorial 3 4 4 
Tutorial 4 3 3 
Tutorial 5 3 3 
Tutorial 6 4 4 
Coursework 100 20 
Exam 100 60 


You should provide a reset button and a calculate button. When the
calculate button is pressed, the average coursework mark (tutorials
and coursework), the exam mark, and the total average for the module
should be calculated and displayed at the top of the form.  You should
check the the form is complete with registration number correctly
formatted before calculating the averages, and use a pop-up window to
let the user know which fields are missing or incorrectly formatted
when necessary.

Please note that you may have to use the parseInt() function:
total=parseInt(number1)+parseInt(number2); to force the addition of
number1+number2 and not concatenate both numbers.

Thank you

Request for Question Clarification by theta-ga on 30 Mar 2003 14:19 PST
Hi purplepit-ga,
   I need a couple of clarifications to answer your question
satisfactorily. First of all, you ask that we check whether the
registeration number is correctly formatted or not. To do this, we
need to know the format of the registeration number. How big is it?
Does it contain alphabets, or digits or both?
Also, I believe that once the user presses the calculate button, you
want three pieces of information shown : The Avg Coursework marks, The
exam mark and the Avg. module marks. But in this case, the exam marks
will be exactly what the user entered in the form. Is this correct?
Finally, the result will be displayed in three textboxes inside a
table. Is this OK?
The remaining part of your question is pretty straightforward, so once
I have your clarifications, I will begin work on it at once.
Regards,
Theta-ga
:-)

Clarification of Question by purplepit-ga on 31 Mar 2003 00:47 PST
Hi there,

And thanks for your help.  In response to you queries, please note...

1) Firstly, let's assume that the student registration number is all
NUMBERS, and is '9' numbers long.

2) Yes, the exam mark will be the same as entered, and the three
textboxes inside a table are fine.

Regards

Anthony

Request for Question Clarification by theta-ga on 31 Mar 2003 07:41 PST
Hi purplepit-ga,
   Just an update. Have finished most of the work. You will have the
solution soon. One query though, in the question you say we are to
calculate the average, but you have also provided weights for each
item. I assume that you want the weighed average calculated, instead
of the plain vanilla one?
Regards,
Theta-ga
:-)

Clarification of Question by purplepit-ga on 31 Mar 2003 10:11 PST
Hi again,
Yes the weighed average is correct!!
and thanks.....

Clarification of Question by purplepit-ga on 01 Apr 2003 13:02 PST
Hi there Theta-ga!!
Just wondering if you received my answer to your last query???
Purplepit
Answer  
Subject: Re: Javascript/html question
Answered By: theta-ga on 01 Apr 2003 22:46 PST
Rated:5 out of 5 stars
 
Hi purpleit-ga,
   Sorry for the delay in posting this solution, but my net connection
had conked out for all of yesterday. :-(
   Anyway, you can download the solution files from the links provided
below.
   The solution consists of the following files:
    - Avg.htm : This is the HTML file that contains the form
    - Avg.js : This is the JavaScript file that conttains the code for
performing the calculations and the data verification.

   As per your requirements, the code performs extensive data
verification and displays any errors found in a seperate popup window.
The following checks are performed:
      - The registeration number should be a numeric value and should
be 9 digits long.
      - The student name must not be left empty.
      - The marks for the various tests should
              - not be empty.
              - be valid nonnegative integer values.
              - not exceed their indicated maximum values.

    I have used the following formula to calculate the weighted
average:
       - Multiply the Marks obtained by the weight to obtain the
weighted marks.
       - Add all the 'weighted marks' together to obtain the 'weighted
sum'
       - Divide this 'weighted sum' by the sum of all the weights to
get the 'weighted average'
    Be sure to verify the results you obtain.

    Due to the large size (mostly the extensive form validation code)
of the Javascript file, I am not posting the source here. You can
download the required files by using the following links:
       [HTML] http://www31.brinkster.com/tanm/GA/Avg.htm
       [Javascript] http://www31.brinkster.com/tanm/GA/avg.js
    To run, put both the files in the same folder, and then load the
HTML file.

    Please test out the file and check out the code thoroughly to
verify that it meets your requirements. If you need any changes made,
post them here, and I will get them done asap.

    The javascript file is well commented, so you should have no
problems in following the code. If you need any clarifications, just
ask!

Regards,
Theta-ga
:-)

Request for Answer Clarification by purplepit-ga on 02 Apr 2003 02:28 PST
Hi there theta-ga,
Thanks for your work on my question, I have saved both of the files
into the same folder as you suggest, but for previous HTML work I was
using a 'HTML validator' here at home to check that html code I'd
written worked, but am unsure of how to run both these files together
using this validadtor? have you any suggestions/ methods you know of??
Thanks in advance for your help.

Purplepit

Clarification of Answer by theta-ga on 02 Apr 2003 02:53 PST
Hi purpleit-ga,
  Just submit the HTML file [Avg.htm] to your HTML validator. As long
as the javascript file is kept in the same folder as the html file, it
should be automatically found if the validator needs it.
Regards,
Theta-ga
:-)
purplepit-ga rated this answer:5 out of 5 stars and gave an additional tip of: $10.00
Fantastic, precise answer as usual!! a great help.......Thank you!

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy