It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

JAVASCRIPT code bug help

JAVASCRIPT code bug help

Postby fanchun on Wed Sep 05, 2007 6:38 pm

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


Code: Select all
<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>
[/code]
fanchun
 
Posts: 0
Joined: Wed Sep 05, 2007 6:36 pm

Re: JAVASCRIPT code bug help

Postby Logician on Mon Sep 10, 2007 8:26 pm

fanchun wrote: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?
The JS console is trying to help you. Look at it in FireFox: Tools/Error Console.
Logician
 
Posts: 20
Joined: Tue Jun 12, 2007 3:43 am
Location: U.K.


Who is online

Users browsing this forum: No registered users and 8 guests