Click here to Skip to main content
15,914,111 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: Javascript, KnockoutJS (and possibly TypeScript) Pin
Payrok17-Jul-13 5:45
Payrok17-Jul-13 5:45 
GeneralRe: Javascript, KnockoutJS (and possibly TypeScript) Pin
_Maxxx_17-Jul-13 13:01
professional_Maxxx_17-Jul-13 13:01 
GeneralLooking for team Pin
ashkanpower17-Jun-13 23:03
ashkanpower17-Jun-13 23:03 
GeneralRe: Looking for team Pin
Richard MacCutchan17-Jun-13 23:35
mveRichard MacCutchan17-Jun-13 23:35 
GeneralRe: Looking for team Pin
ashkanpower18-Jun-13 0:49
ashkanpower18-Jun-13 0:49 
QuestionHTML issue with IE. Pin
InderK17-Jun-13 3:17
InderK17-Jun-13 3:17 
AnswerRe: HTML issue with IE. Pin
Richard Deeming17-Jun-13 4:46
mveRichard Deeming17-Jun-13 4:46 
GeneralRe: HTML issue with IE. Pin
InderK19-Jun-13 1:25
InderK19-Jun-13 1:25 
AnswerRe: HTML issue with IE. Pin
Dholakiya Ankit10-Aug-13 1:43
Dholakiya Ankit10-Aug-13 1:43 
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 

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.