Click here to Skip to main content
15,883,795 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: HTML issue with IE. Pin
Dholakiya Ankit12-Sep-13 1:10
Dholakiya Ankit12-Sep-13 1:10 
Questionjquery/jquerymobile - image inside collapsible>listview Pin
Prasoon Chaudhary13-Jun-13 6:57
Prasoon Chaudhary13-Jun-13 6:57 
QuestionjQuery - getting selected item of dynamic listview Pin
Prasoon Chaudhary13-Jun-13 6:13
Prasoon Chaudhary13-Jun-13 6:13 
AnswerRe: Free java online course Pin
dusty_dex12-Jun-13 2:15
dusty_dex12-Jun-13 2:15 
GeneralRe: Free java online course Pin
Richard MacCutchan12-Jun-13 2:30
mveRichard MacCutchan12-Jun-13 2:30 
GeneralRe: Free java online course Pin
dusty_dex12-Jun-13 7:02
dusty_dex12-Jun-13 7:02 
QuestionPassing objects byref between html windows Pin
tiwal11-Jun-13 23:30
tiwal11-Jun-13 23:30 
QuestionCalling a function from within a function question Pin
Calufrax1211-Jun-13 14:06
Calufrax1211-Jun-13 14:06 
Hello. I am attempting to create a small app that rotates images, with buttons to stop, slow or speed up the animation, or to start/reset.

The button functions work, but when they try to contact another function (setSpeed) or even use setTimeout or setInterval, those are ignored. Putting in other commands in those functions (e.g. window.alert("test") statements yields results, so I know it's doing something.

Any help would be much appreciated...


JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Animation</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">
	<!-- // hide from older browsers
	
	
	/* <![CDATA[ */
	
	var myFx;
	currImage = "pennant2.gif"; // document.getElementById("dhtmlFx").src;
	xName = "dhtmlFx";
	speedVar = 500;
	speedVal = 100;
	maxVal = 1500;
	stopSpeed = 99999;
	var startFlag;
	startFlag = 1;
	y = speedVar;
	//var filename = fullPath.replace(/^.*[\\\/]/, 'currImageObj.src')
		//window.alert(filename);
			
			
	function startMe()
	{
		startFlag = 1;
		myFx = setInterval(doFx, speedVar);
	}
	function doFx()
	{
		currImageObj = document.getElementById(xName);
		myText = document.getElementById("dhtmlText");
		myText.textContent = y;
				
	    if (currImage == "pennant2.gif") { 
		currImageObj.src = "pennant1.gif";
		currImage = "pennant1.gif";
			} else { 
		currImageObj.src = "pennant2.gif";
		currImage = "pennant2.gif";
		}
				
	}
	
	
	function startThis()
	{
		if (startFlag == 0)
		{
		y=speedVar;
		startFlag = 1;
		setSpeed(y);
		} else {
			window.alert(startFlag + " Animation already started");	
		}
	}

	function slower()
	{
		y+=speedVal;
		if (y>= maxVal )
		{
			y=maxVal;
		}
	
		startFlag = 1;
		setSpeed(y);	
	}
	
	function faster()
	{
		startFlag = 1;
	
		y-=speedVal;
		if (y<= 0 )
		{
			y=1;	
		}
		
		if (y > maxVal)
		{
			y = maxVal;	
		}
				
		setSpeed(y);
	}
	
	function stopThis()
	{
		startFlag = 0;
		y = stopSpeed;
		clearInterval(myFx);
	}
	

	function setSpeed(y)
	{
		clearInterval(myFx);
		var myFx = setInterval(doFx,y);
	}
	
	/* ]]>*/
		
	// end remark comment to hide from older browsers
	//-->


</script>
</head>

<body onload="startMe();">
<img id="dhtmlFx" src="pennant2.gif" height="183" width="388" />
<div id="dhtmlText">0</div>

<form action="" name="animate" >
<input type="button" name="buttonStop" value="START" onclick="startThis();">
<input type="button" name="buttonStop" value="<<" onclick="slower();">
<input type="button" name="buttonStop" value=">>" onclick="faster();">
<input type="button" name="buttonStop" value="STOP" onclick="stopThis();">
</form>


</body>
</html>


Thanks!

modified 11-Jun-13 21:15pm.

AnswerRe: Calling a function from within a function question Pin
Dennis E White11-Jun-13 15:40
professionalDennis E White11-Jun-13 15:40 
AnswerRe: Calling a function from within a function question Pin
thanh_bkhn11-Jun-13 15:55
professionalthanh_bkhn11-Jun-13 15:55 
GeneralRe: Calling a function from within a function question Pin
Calufrax1213-Jun-13 15:25
Calufrax1213-Jun-13 15:25 
QuestionEnable / Disable textbox controlled by drop-down menu in PHP Pin
swapnilwebsite11-Jun-13 1:01
swapnilwebsite11-Jun-13 1:01 
QuestionSend Data to ASPX Page Pin
ASPnoob9-Jun-13 4:56
ASPnoob9-Jun-13 4:56 
AnswerRe: Send Data to ASPX Page Pin
Dennis E White9-Jun-13 18:48
professionalDennis E White9-Jun-13 18:48 
QuestionActiveX Object in javascript can not create after host it Pin
kuntala kumari mahanta8-Jun-13 0:38
kuntala kumari mahanta8-Jun-13 0:38 
AnswerRe: ActiveX Object in javascript can not create after host it Pin
Dennis E White8-Jun-13 19:53
professionalDennis E White8-Jun-13 19:53 
GeneralRe: ActiveX Object in javascript can not create after host it Pin
kuntala kumari mahanta9-Jun-13 19:40
kuntala kumari mahanta9-Jun-13 19:40 
GeneralRe: ActiveX Object in javascript can not create after host it Pin
dusty_dex9-Jun-13 22:13
dusty_dex9-Jun-13 22:13 
QuestionPassing Element ID to ASP.net Pin
ASPnoob7-Jun-13 16:31
ASPnoob7-Jun-13 16:31 
AnswerRe: Passing Element ID to ASP.net Pin
Dennis E White8-Jun-13 19:52
professionalDennis E White8-Jun-13 19:52 
GeneralRe: Passing Element ID to ASP.net Pin
ASPnoob9-Jun-13 1:55
ASPnoob9-Jun-13 1:55 
GeneralRe: Passing Element ID to ASP.net Pin
Dennis E White9-Jun-13 18:45
professionalDennis E White9-Jun-13 18:45 
QuestionAs Simple As I Can Make It - SOLUTION Pin
#realJSOP7-Jun-13 7:02
mve#realJSOP7-Jun-13 7:02 
AnswerRe: As Simple As I Can Make It - SOLUTION Pin
Dennis E White8-Jun-13 19:42
professionalDennis E White8-Jun-13 19:42 
QuestionCheckbox checked Java script and c# Pin
sujeet3215-Jun-13 22:43
sujeet3215-Jun-13 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.