JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 3rd, 2005, 09:14 PM
OldManRiver OldManRiver is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 5 OldManRiver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 59 sec
Reputation Power: 0
Call is not right

All,

I have this script, which is driving me crazy. It's a pretty simple one, just text messaging. Somehow, I'm not making the routine call right or not passing the vars.

Here is my code:
Code:
<html>
<script language="JavaScript1.2">
	function init() {
		var txtArray = new Array(5);
		var clrArray = new Array(5);
		var counter = 1;
		txtArray[0] = 'Technology';
		txtArray[1] = 'Talent'
		txtArray[2] = 'Leadership';
		txtArray[3] = 'Solutions';
		txtArray[4] = 'Savings';
		clrArray[0] = '#ffaaaa';
		clrArray[1] = '#aaaaff'
		clrArray[2] = '#aaffaa';
		clrArray[3] = '#999999';
		clrArray[4] = '#000000';
		var txa = txtArray[0]; //initial Message
		var bgc = clrArray[0]; //initial Color
//		setTimeout('init()',2000);//
		return;
	}
</script>

<BODY onload='init()'>
<table width=100% height=100% align=center valign=middle bgcolor=000000 name=target>
	<tr>
	<td align=center>
	<h1>
	<script language="JavaScript">
		var neonbasecolor="gray"
		var neontextcolor="yellow"
		var flashspeed=100
		var n=0
		var xx=0
		var txt = 'Test Message!'
		if (document.all||document.getElementById){
			document.write('<font color="'+neonbasecolor+'">')
			for (m=0;m<txt.length;m++)
			document.write('<span id="neonlight'+m+'">'+txt.charAt(m)+'</span>')
			document.write('</font>')
		} else {
			document.write(txt)
		}

		function crossref(number){
			var crossobj=document.all? eval("document.all.neonlight"+number) : 
			document.getElementById("neonlight"+number)
			return crossobj
		}

		function changeBanner() {
		 	if(counter > 4) counter = 0;
			txa = txtArray[counter];
			bgc = clrArray[counter];
			counter++;
		}

		function neon(){
			if (n==0){  //Change all letters to base color
				for (m=0;m<txt.length;m++)
				crossref(m).style.color=neonbasecolor
			}
			crossref(n).style.color=neontextcolor
//			if (yy==0) {//
//				changeBanner();//
//				txt = txa;//
//				document.target.bgcolor=bgc//
//			}//
			if (n<txt.length-1) {
				n++;
			} else {
				n=0;
				xx++;
				if (xx > 4) {
					xx=0;
					yy++;
					if (yy > 4) yy=0;
				}
				clearInterval(flashing);
				setTimeout("beginneon()",1500);
				return;
			}
		}

		function beginneon(){
			if (document.all||document.getElementById)
			flashing=setInterval("neon()",flashspeed)
		}

		beginneon()
	</script>

	</h1>
	</td>
	</tr>
</table>


The commented area is where I'm having the problem. It hangs on the first Letter and does not set the new string.

Sure hope someone know what I'm doing wrong!

OMR

Reply With Quote
  #2  
Old December 3rd, 2005, 11:38 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 549 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 7 h 3 m
Reputation Power: 4
variables

I played around with it a bit. By declaring var yy = 0; and placing the init() function's variables outside of a function (changing the variables scope to make them available to the other functions). and changing
Code:
document.target.bgcolor=bgc;

to
Code:
var elem = document.getElementById('target');
elem.style.backgroundcolor = bgc;

I was able to get the characters "Text Message!" to change from grey to yellow, sort of. first the "Text M" changed then "Text Mes" then to grey except the "M" and "es". Hopefully this helps some.

Last edited by Mittineague : December 3rd, 2005 at 11:41 PM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Call is not right


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT