need GPA and CGPA calculate code
<p>i have some code but the code is missing some features.<br>
 1. if we selected box, and than the calculation 
 2. if we select value of yes on repeated course. how we calculate new
    gpa and cgpa ?</p>

<p>Script Code</p>

<pre><code>&lt;script type = "text/javascript"&gt;

//function to set the focus on GPA form 
function setFocus() { 
document.GPA.focus(); 
return; 
}


//functio to round 2 decimal points 
function round(n){return(.01* Math.round(100*n));}



//function to calculate gpa 
function calculate(fr) 
{ 





//checking if all credit hours equal to zero 
if (fr.CH1.selectedIndex=="0") 
{alert ("Please specify your credit hours") } 



else 

//calculating 
var resultgpa; 
fr.resultgpa.value=round((eval(fr.CH1.selectedIndex)*parseFloat(fr.grade1.value))
/(eval(fr.CH1.selectedIndex)))

var resultcgpa; 
fr.resultcgpa.value 
=round((eval(fr.CH1.selectedIndex)*parseFloat(fr.grade1.value)+ 
parseFloat(fr.cgpa.value)*parseFloat(fr.TCH.value)) 
/(eval(fr.CH1.selectedIndex)+ 
parseFloat(fr.TCH.value)))



}


&lt;/script&gt;
</code></pre>

<p>HTML Code:</p>

<pre><code>&lt;form action="none" name="GPA"&gt;
&lt;table  width="700" border="3"  align="center" valign="top" &gt; 
&lt;!--creating form to send data to function--&gt; 


    &lt;tr&gt;&lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Select&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
    &lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Courses&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
    &lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Credit&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
    &lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Expected/Grade&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
    &lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Repeted Course&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
    &lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Previous Grade&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 
&lt;td&gt;1. &lt;input type="checkbox" text name="sn1"value="smoker"/&gt;&lt;/td&gt;
&lt;td&gt;&lt;select name="c1"&gt;
&lt;option value="unknown"&gt;Select&lt;/option&gt;
&lt;option&gt;CPE 101&lt;/option&gt;
&lt;option&gt;ENG 101&lt;/option&gt;
&lt;option&gt;ECO 101&lt;/option&gt;
&lt;option&gt;MAT 101&lt;/option&gt;
&lt;option&gt;PHY 101&lt;/option&gt;
&lt;option&gt;HTR 101&lt;/option&gt;
&lt;option&gt;TUR 101&lt;/option&gt;
&lt;option&gt;CPE 112&lt;/option&gt;
&lt;option&gt;ENG 102&lt;/option&gt;
&lt;option&gt;MAT 102&lt;/option&gt;
&lt;option&gt;PHY 102&lt;/option&gt;
&lt;option&gt;CHM 110&lt;/option&gt;
&lt;option&gt;CPE 221&lt;/option&gt;
&lt;option&gt;CLE 201&lt;/option&gt;
&lt;option&gt;CLE 201&lt;/option&gt;
&lt;option&gt;MAT 201&lt;/option&gt;
&lt;option&gt;MAT 205&lt;/option&gt;
&lt;option&gt;XXX XXX&lt;/option&gt;
&lt;option&gt;CPE 222&lt;/option&gt;
&lt;option&gt;ILE 224&lt;/option&gt;
&lt;option&gt;ILE 212&lt;/option&gt;
&lt;option&gt;ILE 232&lt;/option&gt;
&lt;option&gt;MAT 204&lt;/option&gt;
&lt;option&gt;CPE 313&lt;/option&gt;
&lt;option&gt;CPE 321&lt;/option&gt;
&lt;option&gt;CPE 331&lt;/option&gt;
&lt;option&gt;CPE 351&lt;/option&gt;
&lt;option&gt;CPE 341&lt;/option&gt;
&lt;option&gt;CPE 326&lt;/option&gt;
&lt;option&gt;CPE 332&lt;/option&gt;
&lt;option&gt;CPE 342&lt;/option&gt;
&lt;option&gt;CPE 324&lt;/option&gt;
&lt;option&gt;CPE 322&lt;/option&gt;
&lt;option&gt;CPE 411&lt;/option&gt;
&lt;option&gt;CPE 413&lt;/option&gt;
&lt;option&gt;CPE 415&lt;/option&gt;
&lt;option&gt;CPE 400&lt;/option&gt;
&lt;option&gt;CPE 414&lt;/option&gt;
&lt;option&gt;CPE 415&lt;/option&gt;
&lt;/select&gt;&lt;/td&gt;
&lt;td align = "center"&gt; 
&lt;select name= "CH1"&gt; 
&lt;option value = "0" SELECTED&gt;Select 
&lt;option value = "1"&gt;1 
&lt;option value = "2"&gt;2 
&lt;option value = "3"&gt;3 
&lt;option value = "4"&gt;4

&lt;/select&gt;&lt;/td&gt;

&lt;td align = "center" width = "70"&gt; 
&lt;select name= "grade1"&gt; 
&lt;option value = "5" SELECTED&gt;Select 
&lt;option value = "4"&gt;A 
&lt;option value = "3.70"&gt;A- 
&lt;option value = "3.30"&gt;B+ 
&lt;option value = "3"&gt;B 
&lt;option value = "2.70"&gt;B- 
&lt;option value = "2.30"&gt;C+ 
&lt;option value = "2"&gt;C 
&lt;option value = "1.70"&gt;C- 
&lt;option value = "1.30"&gt;D+ 
&lt;option value = "1"&gt;D
&lt;option value = "0.7"&gt;D-  
&lt;option value = "0"&gt;F
&lt;/select&gt;&lt;/td&gt;

    &lt;td&gt; &lt;center&gt;
         &lt;input type="radio" name="1"&gt;Yes
         &lt;input type="radio" name="1"&gt;No
    &lt;/center&gt;&lt;/td&gt;

&lt;td align = "center"&gt; 
&lt;select name= "g1"&gt; 
&lt;option value = "5" SELECTED&gt;Select 
&lt;option value = "4"&gt;A 
&lt;option value = "3.70"&gt;A- 
&lt;option value = "3.30"&gt;B+ 
&lt;option value = "3"&gt;B 
&lt;option value = "2.70"&gt;B- 
&lt;option value = "2.30"&gt;C+ 
&lt;option value = "2"&gt;C 
&lt;option value = "1.70"&gt;C- 
&lt;option value = "1.30"&gt;D+ 
&lt;option value = "1"&gt;D
&lt;option value = "0.7"&gt;D-  
&lt;option value = "0"&gt;F

&lt;/select&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;table width="400" border="3" align="center" valign="top"&gt; 


&lt;tr&gt; 
&lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt; Your Current CGPA:&lt;/b&gt;&lt;/p&gt; &lt;/td&gt;&lt;td align="right"&gt;&lt;input type = text name="cgpa"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Your Credit Hours Taken Is:&lt;/b&gt;&lt;/p&gt; &lt;/td&gt;&lt;td align="right"&gt;&lt;input type = text name="TCH"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;/table&gt;

&lt;table width="400" border="3" align="center" valign="top"&gt; 





&lt;!--sending information to calculate() function--&gt;

&lt;!--getting back result from function--&gt; 
&lt;tr&gt;&lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Your GPA Will Be:&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; 
&lt;td align="right"&gt;&lt;input type = text name="resultgpa"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!--getting back result from function--&gt; 
&lt;tr&gt;&lt;td&gt;&lt;p align="center"style="font-size:16pt"&gt;&lt;b&gt;Your CPGA Will Be:&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; 
&lt;td align="right"&gt;&lt;input type = text name="resultcgpa"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;&lt;input type = "button" value = "Calculate!" onclick = "calculate(this.form)" name = "bottun"&gt;&lt;/td&gt;

&lt;!--reset button--&gt; 
&lt;td align="right"&gt;&lt;input type="reset" name="reset" value="Clear"&gt;

&lt;/td&gt;&lt;/tr&gt; 
&lt;/table&gt;
&lt;/form&gt;
</code></pre>
