Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts

    Function causing .asp page malfunction

    I have the following javascript/text function:
    Code:
    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:
    Code:
    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....

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    post full code please.

  • #3
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    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...

  • #4
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    I need at least the html code and the place where you are calling the method.

  • #5
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    here is the only function where i call the method from. i highlighted the calls in red for you:
    Code:
    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');
    				}
    		}			
      }
    }

  • #6
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    where are you calling the method checkAnswer.

  • #7
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by ckeyrouz View Post
    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:
    Code:
    <div id="checkanswer1-1" onclick="checkAnswer('1','1')"></div>

  • #8
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    Can you try calling the method from another place, like adding a button for testing purpose.

  • #9
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by ckeyrouz View Post
    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...

  • #10
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    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

  • Users who have thanked ckeyrouz for this post:

    ajetrumpet (07-18-2009)

  • #11
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    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:
    Code:
    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...

  • #12
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Code:
    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
    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)

  • #13
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by barkermn01 View Post

    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
    thank you for saying so barker. i will add all of the semicolons i need to in my pages. i appreciate the input


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •