...

View Full Version : Function causing .asp page malfunction



ajetrumpet
07-18-2009, 01:46 AM
I have the following javascript/text function:
function ChangeProblem(ProbNum) {
if (ProbNum == '1')
{
document.getElementById('word1').innerHTML = "The"
document.getElementById('word2').innerHTML = "Went"
document.getElementById('word3').innerHTML = "The"
document.getElementById('word4').innerHTML = "Light"
document.getElementById('word5').innerHTML = "Through"
document.getElementById('word6').innerHTML = "Car"
}
else if (ProbNum == '2')
{
document.getElementById('word1').innerHTML = "Jumped"
document.getElementById('word2').innerHTML = "Cow"
document.getElementById('word3').innerHTML = "Over"
document.getElementById('word4').innerHTML = "Moon"
document.getElementById('word5').innerHTML = "The"
document.getElementById('word6').innerHTML = "The"
else
{
document.getElementById('word1').innerHTML = "The"
document.getElementById('word2').innerHTML = "Drive"
document.getElementById('word3').innerHTML = "Right"
document.getElementById('word4').innerHTML = "Always"
document.getElementById('word5').innerHTML = "Trucks"
document.getElementById('word6').innerHTML = "On"
}
}in another function, i am calling this by using this line:
ChangeProblem('1') or other number params.

with this function in my .asp page code, the page does not work at all. all of the other code seems to be disabled. if i comment this function out, and all it's function calls from other places in the code, the page runs just fine. can someone please help me here? i don't see a problem with it that i can recognize with my limited skills. thank you....

ckeyrouz
07-18-2009, 01:49 AM
post full code please.

ajetrumpet
07-18-2009, 01:50 AM
i have 832 lines of code in my page. do you want all of it, or just the js functions? i only have one type of functions in the page, that's js script. i am not experienced in js at all, so the page could've been written in 200 lines at max, i'm sure...

ckeyrouz
07-18-2009, 01:52 AM
I need at least the html code and the place where you are calling the method.

ajetrumpet
07-18-2009, 01:55 AM
here is the only function where i call the method from. i highlighted the calls in red for you:
function checkAnswer(whichPlayNum,whichTry) {
var Answer1 = "The Car Went Through The Light"
var Answer1ALT1 = " The Car Went Through The Light"
var Answer1ALT2 = "The Car Went Through The Light "
var Answer1ALT3 = " The Car Went Through The Light "

var Answer2 = "The Cow Jumped Over The Moon"
var Answer2ALT1 = " The Cow Jumped Over The Moon"
var Answer2ALT2 = "The Cow Jumped Over The Moon "
var Answer2ALT3 = " The Cow Jumped Over The Moon "

var Answer3 = "Trucks Always Drive On The Right"
var Answer3ALT1 = " Trucks Always Drive On The Right"
var Answer3ALT2 = "Trucks Always Drive On The Right "
var Answer3ALT3 = " Trucks Always Drive On The Right "

if (whichPlayNum == '1')
{
if (document.getElementById('answer').innerHTML == Answer1 || document.getElementById('answer').innerHTML == Answer1ALT1 ||
document.getElementById('answer').innerHTML == Answer1ALT2 || document.getElementById('answer').innerHTML == Answer1ALT3)
{
EvalSound('1Reinforcement');
ClearAnswer();
RightAnswer();
PlaysRemain();
ChangeProblem('2');
DisableCheckAnswer();
checkAnswerButton('checkanswer1-2');
}
else
{
if (whichTry == '1')
{
EvalSound('NotCorrect4');
ClearAnswer();
DisableCheckAnswer();
checkAnswerButton('checkanswer1-1');
}
else
{
EvalSound('NotCorrect4');
ClearAnswer();
WrongAnswer();
PlaysRemain();
ChangeProblem('2');
DisableCheckAnswer();
checkAnswerButton('checkanswer1-2');
}
}
}
else if (whichPlayNum == '2')
{
if (document.getElementById('answer').innerHTML == Answer2 || document.getElementById('answer').innerHTML == Answer2ALT1 ||
document.getElementById('answer').innerHTML == Answer2ALT2 || document.getElementById('answer').innerHTML == Answer2ALT3)
{
EvalSound('2Reinforcement');
ClearAnswer();
RightAnswer();
PlaysRemain();
ChangeProblem('3');
DisableCheckAnswer();
checkAnswerButton('checkanswer2-2');
}
else
{
if (whichTry == '1')
{
EvalSound('NotCorrect4');
ClearAnswer();
DisableCheckAnswer();
checkAnswerButton('checkanswer2-1');
}
else
{
EvalSound('NotCorrect4');
ClearAnswer();
WrongAnswer();
PlaysRemain();
ChangeProblem('3');
DisableCheckAnswer();
checkAnswerButton('checkanswer2-2');
}
}
}
else
{
if (document.getElementById('answer').innerHTML == Answer3 || document.getElementById('answer').innerHTML == Answer3ALT1 ||
document.getElementById('answer').innerHTML == Answer3ALT2 || document.getElementById('answer').innerHTML == Answer3ALT3)
{
EvalSound('3Reinforcement');
ClearAnswer();
RightAnswer();
PlaysRemain();
ChangeProblem('1');
DisableCheckAnswer();
checkAnswerButton('checkanswer3-2');
}
else
{
if (whichTry == '1')
{
EvalSound('NotCorrect4');
ClearAnswer();
DisableCheckAnswer();
checkAnswerButton('checkanswer3-1');
}
else
{
EvalSound('NotCorrect4');
ClearAnswer();
WrongAnswer();
PlaysRemain();
ChangeProblem('1');
DisableCheckAnswer();
checkAnswerButton('checkanswer3-2');
}
}
}
}

ckeyrouz
07-18-2009, 01:56 AM
where are you calling the method checkAnswer.

ajetrumpet
07-18-2009, 01:59 AM
where are you calling the method checkAnswer.from the onclick event of an AP DIV in Dreamweaver CS4. here is an example of one call:
<div id="checkanswer1-1" onclick="checkAnswer('1','1')"></div>

ckeyrouz
07-18-2009, 02:06 AM
Can you try calling the method from another place, like adding a button for testing purpose.

ajetrumpet
07-18-2009, 03:22 AM
Can you try calling the method from another place, like adding a button for testing purpose.i tried adding a button ckey, but that doesn't work either. but...the changeproblem() function was not commented out either. if it is just there, i can't do anything. not sure where to go from here. do you have any more suggestions? thanks...

ckeyrouz
07-18-2009, 04:38 AM
Try putting alerts between every lines of the function checkAnswer and check where it stops.

The place where it stops it contains errors

for example
try alert(1) then alert(2) etc...

and check the last number you see in the alert

ajetrumpet
07-18-2009, 06:54 AM
you won't believe this ckey, but i found the error. you can see there is an error in my first post. I am missing an ending bracket in the ELSE IF section:
function ChangeProblem(ProbNum) {
if (ProbNum == '1')
{
document.getElementById('word1').innerHTML = "The"
document.getElementById('word2').innerHTML = "Went"
document.getElementById('word3').innerHTML = "The"
document.getElementById('word4').innerHTML = "Light"
document.getElementById('word5').innerHTML = "Through"
document.getElementById('word6').innerHTML = "Car"
}
else if (ProbNum == '2')
{
document.getElementById('word1').innerHTML = "Jumped"
document.getElementById('word2').innerHTML = "Cow"
document.getElementById('word3').innerHTML = "Over"
document.getElementById('word4').innerHTML = "Moon"
document.getElementById('word5').innerHTML = "The"
document.getElementById('word6').innerHTML = "The"
}
else
{
document.getElementById('word1').innerHTML = "The"
document.getElementById('word2').innerHTML = "Drive"
document.getElementById('word3').innerHTML = "Right"
document.getElementById('word4').innerHTML = "Always"
document.getElementById('word5').innerHTML = "Trucks"
document.getElementById('word6').innerHTML = "On"
}
}thank you so much for your help. i really do appreciate it...

barkermn01
07-18-2009, 06:42 PM
function ChangeProblem(ProbNum) {
if (ProbNum == '1')
{
document.getElementById('word1').innerHTML = "The"
document.getElementById('word2').innerHTML = "Went"
document.getElementById('word3').innerHTML = "The"
document.getElementById('word4').innerHTML = "Light"
document.getElementById('word5').innerHTML = "Through"
document.getElementById('word6').innerHTML = "Car"
}
else if (ProbNum == '2')
{
document.getElementById('word1').innerHTML = "Jumped"
document.getElementById('word2').innerHTML = "Cow"
document.getElementById('word3').innerHTML = "Over"
document.getElementById('word4').innerHTML = "Moon"
document.getElementById('word5').innerHTML = "The"
document.getElementById('word6').innerHTML = "The"
else
{
document.getElementById('word1').innerHTML = "The"
document.getElementById('word2').innerHTML = "Drive"
document.getElementById('word3').innerHTML = "Right"
document.getElementById('word4').innerHTML = "Always"
document.getElementById('word5').innerHTML = "Trucks"
document.getElementById('word6').innerHTML = "On"
}
}


is misssing a shed load of ";"'s so really you should check all stuff like that some browser allow you to use functions without ; others dont you shoudl allwasy put it in, but i still dont see how this is stoping the asp pahe from loading as it is not an ASP Error

ajetrumpet
07-18-2009, 07:17 PM
is misssing a shed load of ";"'s so really you should check all stuff like that some browser allow you to use functions without ; others dont you shoudl allwasy put it in, but i still dont see how this is stoping the asp pahe from loading as it is not an ASP Errorthank you for saying so barker. i will add all of the semicolons i need to in my pages. i appreciate the input



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum