Find jobs - Debt Consolidation - Web Hosting - Gavin Newsom - Online Advertising

PDA

View Full Version : Help needed with Find Button Please....


nothing2add
Dec 3rd 2006, 3:22 pm
Hello all,

I have working on a program which should be able to summarise the results for a module, showing the number of students in each grade category, and overall number passing & failing, with an average mark for all students and an average mark for passing students. I have done that so far, but I am stuck at creating a Find button which will look for stored student & display result or error message if not found.

I have created a three pages one of which is the main page with frames in it to bring the other two pages ( the module_studenData, and the ResultDisplay)


The code for the mainpage (MainPage.html) program is as below:

========================
<HTML>
<HEAD>
<TITLE>JavaScript Programming “Module Student Results”</TITLE>
</HEAD>
<FRAMESET COLS = "50%, 50%">
<FRAME NAME = "DataFrame" SRC = "Module_studentData.htm">
<FRAME NAME = "ResultDisplayForm" SRC = "Resultdisplay.html">
</FRAMESET>
</HTML>
========================
========================

The code for the (Module_studentData.htm) program is as below:

========================
<HTML>
<HEAD>
<TITLE>JavaScript Programming “Module Student Results” </TITLE>
<SCRIPT language=JavaScript>
document.bgColor = '#D6DFF7';
document.fgColor = '#008080';
//Global Variables
var ModCode;
var ModTitle;
var ModExam = 0;
var ModCw = 0;
var StData = new Array ();
var StIndex;
TxtDisplay = "EXAMINATION SYSTEM"

// This Function is Used to save Module Data
// Getting the values and saving into Global Variables
// StIndex=studentindex , StData=studentData

function SaveMod()
{
ModCode = document.ModForm.ModCode.value;
ModTitle = document.ModForm.ModTitle.value;
ModExam = document.ModForm.ModExam.value;
ModCw = document.ModForm.ModCw.value;

// Data Validation
if (ModCode.length == 0)
{
alert (" ERROR: Please type Module Code");
aField.focus();
}//end if
if (ModTitle.length == 0)
{
alert (" ERROR: Please type your Module Title");
aField.focus();
}//end if
if (ModCw.length == 0)
{
alert (" ERROR: Please type Module Course work % weighting");
aField.focus();
}//end if
if (ModExam.length == 0)
{
alert (" ERROR: Please type Module Exam % weighting");
aField.focus();
}//end if
if ((ModExam < 0)||(ModExam > 100))
{
alert("ERROR: Please enter a value In the range" + 0 + " to " + 100);
aField.focus();
}//end if
if ((ModCw < 0)||(ModCw > 100))
{
alert("ERROR: Please enter a value\n In the range" + 0 + " to " + 100);
aField.focus();
}//end if
if (isNaN(ModCw))// if the value of the 3rd input is not a numeric
{
alert("The third input must be numeric.")
aField.focus();
}//end if
if (isNaN(ModExam))// if the value of the 4th input is not a numeric
{
alert("The Fourth input must be numeric.")
aField.focus();
}//end if

// display the Module Data
alert("Module = " + ModCode + "," + ModTitle + ", CourseWork " + ModCw + "%, Exam " + ModExam +"%");
TxtDisplay = TxtDisplay + "\nmodule Code:" + ModCode + ", Name :"+ ModTitle + "\n CourseWork % " + ModCw + ", Exam % " + ModExam + " Saved";
document.ShowResultForm.TxtArea.value = TxtDisplay;



}

//This function is used for Student data Saving into Array of StData
//Getting values and saving into Array

function SaveStu()
{
StIndex = StData.length;

StData[StIndex] = new Object;

with (document.studentForm)
{
StData[StIndex].Id = StID.value;
StData[StIndex].Name = StName.value;
StData[StIndex].Gender = StGender.value;
StData[StIndex].CourseWork = StCW.value;
StData[StIndex].Exam = StExam.value;
StData[StIndex].Grade = ResultCalculation(eval(StCW.value),eval(StExam.value));

// Data Validation
if (StData[StIndex].Id.length == 0)
{
alert (" ERROR: Please type The Student ID");
aField.focus();
}//end if
if (StData[StIndex].Name.length == 0)
{
alert (" ERROR: Please type The Student name");
aField.focus();
}//end if
if (StData[StIndex].Gender.length == 0)
{
alert (" ERROR: Please type The Student Gender");
aField.focus();
}//end if
if (StData[StIndex].CourseWork.length == 0)
{
alert (" ERROR: Please type CourseWork result");
aField.focus();
}//end if
if (StData[StIndex].Exam.length == 0)
{
alert (" ERROR: Please type Exam result");
aField.focus();
}//end if
if ((StData[StIndex].Exam < 0)||(StData[StIndex].Exam > 100))
{
alert("ERROR: Please enter a value\n In the range" + 0 + " to " + 100);
aField.focus();
}//end if
if (isNaN(StData[StIndex].CourseWork))
// if the value of the 4th input is not a numeric
{
alert("The Fourth input must be numeric.")
aField.focus();
}//end if
if (isNaN(StData[StIndex].Exam))
// if the value of the 5th input is not a numeric
{
alert("The Fifth input must be numeric.")
aField.focus();
}//end if


}

with(StData[StIndex])
{
alert("Student Details = " + StData[StIndex].Id + "," + StData[StIndex].Name + "," + StData[StIndex].Gender + ", CourseWork " + StData[StIndex].CourseWork + "%, Exam " + StData[StIndex].Exam +"%"+ ",Grade" + StData[StIndex].Grade );
TxtDisplay = TxtDisplay + "\nStudent ID:" + Id + ", Name :"+ Name + ", Gender: " + Gender + "\n CourseWork: " + CourseWork + ", Exam: "+ Exam + ", Grade: "+ Grade +" Saved";
document.ShowResultForm.TxtArea.value = TxtDisplay;
}
}

//This Function is using for the Grade calculation
//Calling in Upper function savestu()
function ResultCalculation( CourseWork, Exam)
{
var Grade;
result = (CourseWork*ModCw/100 + Exam*ModExam/100);
if (result >= 70)
{
Grade = 'D';
}//end if
if ((result>= 60)&&(result < 70))
{
Grade = 'M';
}//end if
if ((result >= 40)&&(result < 60))
{
Grade = 'P';
}//end if
if ((result >= 30)&&(result < 40))
{
Grade = 'F1';
}//end if
if (result < 30)
{
Grade = 'F2';
}//end if

return Grade;
}

//This Function is used to round the values
//Its using in ResultCalculation.


//Function for Display Records

function DisplayResult()
{
var UnAvailable = "No Record Exists";
if (StData.length > 0)
{
UnAvailable = "List of the students";
}
with (parent.ResultDisplayForm.document)
{
open();
write("<HTML><HEAD><TITLE>Student Results</TITLE>");
write("</HEAD>");
write("<BODY BGCOLOR = " + 'CC,FF,CC' + ">");
write("<font color = " + '00,33,CC' + ">");
write("<CENTER><H3>RESULT OF MODULE :" + ModTitle + " </H3>");
write("<CENTER><H3> "+ UnAvailable + " </H3>");
write("<TABLE BORDER = 3 >");
write("<TR><TD><B>Student ID</B></TD><TD><B>Name</B></TD><TD><B>Gender</B></TD>");
write("<TD><B>CourseWork</B></TD><TD><B>Exam</B></TD><TD><B>Grade</B></TD>");
for (var i = 0; i < StData.length; i++)
{
with (StData[i])
{
write("<TR><TD>" + Id + "</TD><TD> " + Name + "</TD><TD>" + Gender + "</TD><TD>" + CourseWork + "</TD>");
write("<TD>" + Exam + "</TD><TD>" + Grade + "</TD></TR>");
}
}
write("</TABLE>");
write("</CENTER>");
write("</BODY></HTML>");
close();
}

}



</SCRIPT>
<FORM name=ModForm><center>
<p><h2><i><u>Module Details:</u></i></h2><br>
<P>Code: <INPUT size=10 name=ModCode>
Title: <INPUT size=20 name=ModTitle>
<P>Coursework % weighting: <INPUT size=5 name=ModCw>
Exam % weighting: <INPUT size=5 name=ModExam>
<P><INPUT onclick=SaveMod(); type=button value="Save">
<INPUT onclick=document.ModForm.ModCode.focus(); type=reset value=Reset>
</FORM>
<p align="center">=================================</p>
<FORM name=studentForm><center>
<p><h2><i><u>Student Details:</u></i></h2><br>
<P>ID: <INPUT size=10 name=StID>
Name: <INPUT size=20 name=StName>
Gender: <INPUT size=5 name=StGender>
<P>CourseWork %: <INPUT size=10 name=StCW>
Exam %: <INPUT size=10 name=StExam>
<P><INPUT onclick=SaveStu(); type=button value="Save">
<INPUT onclick=document.studentForm.StID.focus(); type=reset value=Reset>
<p align="center">=================================</p>
<P><INPUT onclick=DisplayResult(); type=button value="Show Result">
<INPUT onclick=findData(); type=button value="Find">
<SCRIPT>document.studentForm.StID.focus();
</SCRIPT>
</FORM>
<FORM name=ShowResultForm><TEXTAREA name=TxtArea rows=5 cols=50></TEXTAREA>
</FORM>
<SCRIPT>document.ShowResultForm.TxtArea.value = TxtDisplay; </SCRIPT>
</P>
</BODY>
</HTML>
========================
========================

The code for the (ResultDisplay.html) program is as below:

========================
<HTML>
<HEAD>
<TITLE>Display</TITLE>
<SCRIPT TYPE = "text/javascript">
document.bgColor = "#D6DFF7";
document.fgColor = "#008080";
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<p><h1><i><u>Module & Sudent details:-</u></i></h1><br>
</BODY>
</HTML>

========================


Thanks in advance,

Nothing2add