Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
assuming i have 7 textfields as listed below
1. Subject1
2. subject2
3. subject3
4. subject4
5. subject5
6. subject6
7. Subject7
8.Output Score
9.Button
how do i calculate the percentage if the student don't offer all the 7 subjects ?

HERE IS THE FORM CODE
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="900">
    <tr>
      <td width="79">Subject1:</td>
      <td width="809"><input type="text" name="textfield" placeholder="Enter Score"/></td>
    </tr>
    <tr>
      <td>Subject2:</td>
      <td><input type="text" name="textfield2" placeholder="Enter Score"/></td>
    </tr>
    <tr>
      <td>Subject3:</td>
      <td><input type="text" name="textfield3" placeholder="Enter Score"/></td>
    </tr>
    <tr>
      <td>Subject4:</td>
      <td><input type="text" name="textfield4" placeholder="Enter Score"/></td>
    </tr>
    <tr>
      <td>Subject5:</td>
      <td><input type="text" name="textfield5" placeholder="Enter Score"/></td>
    </tr>
    <tr>
      <td>Subject6:</td>
      <td><input type="text" name="textfield6" placeholder="Enter Score"/></td>
    </tr>
    <tr>
      <td>Subject7:</td>
      <td><input type="text" name="textfield7" placeholder="Enter Score"/></td>
    </tr>
    <tr>
      <td>Output:</td>
      <td><input type="text" name="textfield8" placeholder="Display percentage"/></td>
    </tr>
    <tr>
      <td> </td>
      <td><input type="submit" name="Submit" value="Calculate! " /></td>
    </tr>
  </table>
</form>
</body>
</html>
Posted
Updated 21-Dec-14 5:17am
v2
Comments
Marcin Kozub 21-Dec-14 11:18am    
Percentage of what? Your question is not clear.
jeffabbey25 21-Dec-14 16:09pm    
for grading. maximum score per subject is 100 i.e if a student gets 50 in 7 subjects, it should be (350/700)*100. that is to say (total score/number of subject)*100. i want it to calculate base on the subject offered.
Marcin Kozub 22-Dec-14 3:46am    
You know how to calculate percentage, so what is your real problem?
jeffabbey25 22-Dec-14 6:14am    
i dont think u get the question. am working on a grading system that contains 7 textfield. i want it to calculate itself base on the number of subject offered i.e it might be one subject,2,3,4,5. i want it to be conditional where as the number of subject offered should be used to get the appropriate percentage output.

1 solution

Take a count of the number of subjects he is taking.
Then take the sum of his score and divide it by this count.
 
Share this answer
 
Comments
jeffabbey25 21-Dec-14 15:42pm    
i need a script to automatically take the sum of the textfield filled and do the mathematics

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900