Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript bug help

Status
Not open for further replies.

javascript08

Programmer
Joined
Sep 5, 2007
Messages
1
Location
US
I created an interface using javascript. basically, the function is to create a fomula to calculate values based on inputs in the text box.

but there is a bug when i ran it, is there anyone can help me figure it out? what is wrong with my coding? I attached the coder in html file below.

Thanks

Chun


<html>
<head>
<title>Predicted Modeling Decision Tree Formula</title>
<style type='text/css'>* { font-size: 12pt;}</style>
<h1><font size='50'><b>Predictive Modeling by Decision Tree</b></font></h1><br>
<FORM NAME="form1">
<INPUT TYPE='text' NAME='Learner_Citizenship ' ID='Learner_Citizenship ' size='2'>Learner_Citizenship
<br>
<INPUT TYPE='text' NAME='Learner_Number_Of_Transferred_Credits ' ID='Learner_Number_Of_Transferred_Credits ' size='2'>Learner_Number_Of_Transferred_Credits
<br>
<INPUT TYPE='text' NAME='Primary_Program_Degree ' ID='Primary_Program_Degree ' size='2'>Primary_Program_Degree
<br>
<INPUT TYPE='text' NAME='Quarter_Number_Since_1991 ' ID='Quarter_Number_Since_1991 ' size='2'>Quarter_Number_Since_1991
<br>
<INPUT TYPE='text' NAME='X_N_ACDEARC_C ' ID='X_N_ACDEARC_C ' size='2'>X_N_ACDEARC_C
<br>
<td valign='bottom'><INPUT TYPE='button' VALUE='Calculate' onClick='Go()'></td>
<input type='reset' >
</FORM>
<script type='text/javascript'>
function Go()
{
document.getElementById('results1').innerHTML = "";
var R=0;
var Learner_Citizenship =document.getElementById('Learner_Citizenship ').value;
var Learner_Number_Of_Transferred_Credits =document.getElementById('Learner_Number_Of_Transferred_Credits ').value;
var Primary_Program_Degree =document.getElementById('Primary_Program_Degree ').value;
var Quarter_Number_Since_1991 =document.getElementById('Quarter_Number_Since_1991 ').value;
var X_N_ACDEARC_C =document.getElementById('X_N_ACDEARC_C ').value;
if((1 <= X_N_ACDEARC_C)
){
R=0.198}
else if((Primary_Program_Degree=='XX')
&&(X_N_ACDEARC_C < 1)
){
R=0.219}
else if((Learner_Citizenship=='UNK')
&&(string(' PH MS MB').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.803}
else if((Learner_Number_Of_Transferred_Credits < 83.5)
&&(string(' CE BS').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.846}
else if((Learner_Number_Of_Transferred_Credits < 4.5)
&&(string(' USA NOT').IndexOf(Learner_Citizenship) >0)
&&(string(' PH MS MB').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.691}
else if((51.5 <= Quarter_Number_Since_1991)
&&(83.5 <= Learner_Number_Of_Transferred_Credits)
&&(string(' CE BS').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.718}
else if((Quarter_Number_Since_1991 < 45.5)
&&(4.5 <= Learner_Number_Of_Transferred_Credits)
&&(string(' USA NOT').IndexOf(Learner_Citizenship) >0)
&&(string(' PH MS MB').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.461}
else if((45.5 <= Quarter_Number_Since_1991)
&&(4.5 <= Learner_Number_Of_Transferred_Credits)
&&(string(' USA NOT').IndexOf(Learner_Citizenship) >0)
&&(string(' PH MS MB').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.632}
else if((Quarter_Number_Since_1991 < 49.5)
&&(83.5 <= Learner_Number_Of_Transferred_Credits)
&&(string(' CE BS').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.69}
else if((49.5 <= Quarter_Number_Since_1991 < 51.5)
&&(83.5 <= Learner_Number_Of_Transferred_Credits)
&&(string(' CE BS').IndexOf(Primary_Program_Degree) >0)
&&(X_N_ACDEARC_C < 1)
){
R=0.304}
document.getElementById('results1').innerHTML=R
}
</script>
</head>
<p><b>Predicted Score <div style= 'color: #FF0000' id='results1'></div></b></p>
</body>
</html>
 
Why do you have everything in the <HEAD> tag? I would say that is the first thing you are doing wrong. Try moving everything from the <H1> tag to the </FORM> tag into the body and see what that does.

Einstein47
“Evil abounds when good men do nothing.“ - Nelson R.
[&#91;]Starbase47.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top