hello. first i read the stickies and searched for my problem ?
and btw sorry for my poor English ?
i am beginner at javascript. i want to make a script that calculates the GPA… i want to use <select><option> (drop-down). so i want user not to use keyboard..
lets say there are 5 class (in fact there will be more than 50) and because of this i dont want to write 50 times these tags
<option value=A>4</option>
<option value=B>3</option>
.
.
<option value=F>0</option>
i will use loop for this. and here comes my problem..
i will only write 1 <select><option> and javascript make it more. the script multiply grade and credits. then sum them up and at last divide the sum by totalcredit.
<html>
<head>
<script language=”javascript” type=”text/javascript”>
for (i=1 ;i<5 ;i++ )
{document.write(“<form name=creditform”
+[i]
+”>”
+”<select id=creditvalue”+[i]+”>”
+”<option value=1>1</option>”
+”<option value=2>2</option>”
+”</select>”
+”<select id=gradevalue”+[i]+”>”
+”<option value=4>A</option>”
+”<option value=3>B</option>”
+”</select>”
+”</form>”
);}
document.write(“<form name=lastform>”
+”<input type=button value=RESULT onclick=hesaplama();>”
+”<input type=text name=showresult>”
+”</form>”
)
var creditt;[i]=document.getElementById(“creditvalue”+[i])
var creditselect;[i]=creditt[i].options[creditt[i].selectedIndex].value;
var gradee;[i]=document.getElementById(“gradevalue”);
var gradeselect;[i]=gradee[i].options[gradee[i].selectedIndex].value;
multiplyresult= new Array();
multiplyresult= new Array();
multiplyresult[i]=gradeselect[i]*creditselect[i];
totalmultiplyresult=0;
totalmultiplyresult+=multiplyresult[i];
totalcredit=0;
totalcredit+=creditselect[i];
mainresult=totalmultiplyresult/totalcredit;
</script>
<script language=”javascript” type=”text/javascript”>
function hesaplama()
{
document.lastform.showresult.value=mainresult;
}
</script>
</head>
</html>