Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

function is not defined error.


  • Please log in to reply
2 replies to this topic

#1 Ray Parrish

Ray Parrish

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Cottage Grove, Oregon
  • Local time:01:53 PM

Posted 13 March 2010 - 12:15 PM

Hello,

Once again I am stuck... Why is JavaScript so picky??? I am getting the error that

setVisitCounts is not defined
setMozillaCounts is not defined

and I have no idea why, they are clearly both defined in the following code as far as I can tell, and I am not spotting any more errors after the first five or six I eliminated...

<script type="text/javascript">

function setCounts(AgentNames, RangeSize, DaysCounts, BrowserTotal) {
	 var BrowserAbbrs = ["Moz", "F.F.", "I.E.", "G.C.", 'Sea"]
	 var BrowserNames= ["Mozilla", "Firefox", "Internet Explorer", "Google Chrome", "Seamonkey"]
	 var BrowserBarString = "";
	 var BrowserBar = 0;
	 var BowserBarRight = 0;
	 var BrowserBarWidth = 0;
	 var BarNumber = 0
	 for (LoopCount in DaysCounts) {
		  BarNumber ++;
		  BarName = "bar" + BarNumber;
		  document.getElementById(BarName).style.height= ((300.0 / RangeSize) * DaysCounts[LoopCount]);
		  document.getElementById(BarName).title= DaysCounts[LoopCount] + " " + AgentNames + "s";
		  }
	 // <div class="browserbar" id="browserbar1" title="Mozilla - 120" style="position: absolute; right: 90%; width: 10%; background-color: #DF5F5E;">Moz</div> Write the previous sample for each BrowserBar in the BrowserBar collection. //
	 for LoopCount in BrowserTotal {
		  BrowserBar ++;
		  BrowserBarWidth = (100.0 / RangeSize) * BrowserTotal[LoopCount];
		  BrowserBarRight = 100 - BrowserBarWidth - BrowserBarRight;
		  BrowserBarString = BrowserBarString + "<div class=\"browserbar\" id=\"browserbar" + BrowserBar + "\" title=\"" + BrowserNames[LoopCount] + " - " + BrowserTotal[LoopCount] + "\" style=\"position: absolute; right: " + BrowserBarRight + "%; width: " + BrowserBarWidth + "%; background-color: #DF5F5E;\">" + BrowserAbbrs[LoopCount] + "</div>";
		  document.getElementById('browserchart1').innerHTML= BrowserBarString;
	 }

	 document.getElementById('titlebar').innerHTML= "<center>February 2009 " + AgentNames + " Counts</center>";
	 document.getElementById('increment2').innerHTML= (RangeSize / 6.0)
	 document.getElementById('increment3').innerHTML= ((RangeSize / 6.0) * 2);
	 document.getElementById('increment4').innerHTML= ((RangeSize / 6.0) * 3);
	 document.getElementById('increment5').innerHTML= ((RangeSize / 6.0) * 4);
	 document.getElementById('increment6').innerHTML= ((RangeSize / 6.0) * 5);
	 document.getElementById('increment7').innerHTML= ((RangeSize / 6.0) * 6);
	 }

function setVisitCounts() {
	 var AgentName = "Visit";
	 var Range = 3000;
	 var VisitCounts = [2500, 1550, 1777, 1134, 1555, 2888, 1000, 1550, 1609, 1806, 1444, 1555, 1876, 1456, 1678, 1987, 1150, 1560, 2179, 1678, 1984, 1542, 1567, 1420, 1000, 1444, 1777, 1904];
	 var BrowserTotals = [120, 480, 240, 180, 180];
	 setCounts(AgentName, Range, VisitCounts, BrowserTotals);
	 }

function setMozillaCounts() {
	 var AgentName = "Mozilla Browser";
	 var Range = 1200;
	 var MozillaCounts = [923, 650, 777, 1134, 555, 888, 1000, 550, 609, 806, 444, 555, 876, 456, 678, 987, 1150, 560, 179, 678, 984, 542, 567, 420, 1000, 444, 777, 904];
	 var BrowserTotals - [120, 480, 240, 180, 180];
	 setCounts(AgentName, Range, MozillaCounts, BrowserTotals);
	 }
</script>

Sorry to be such a pest, one of these days I will have learned JavaScript, and will quit bugging you.8-)

Thanks, Ray Parrish

Me again,

I've installed Firebug, and it shows the script when I click on HTML, but when I try clicking script, after selecting Script's menu entry "Enable" the script does not show. That's pretty strange but fits with the error I am getting from the Error Console which is "setMozillaCounts is not defined".

According the Firebug then, none of those functions are defined, and I can not fathom why, as I had the functions all working until I added the code for the BrowserBar HTML generation.

How in the heck did I break this script?

Thanks for any help you can be, Ray Parrish

Edited by Ray Parrish, 13 March 2010 - 01:59 PM.


BC AdBot (Login to Remove)

 


#2 Ray Parrish

Ray Parrish
  • Topic Starter

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Cottage Grove, Oregon
  • Local time:01:53 PM

Posted 13 March 2010 - 04:42 PM

Hello again,

Well, I got it ironed out by removing all of the changes I had made, and then putting them back one at a time carefully. The graph's script is once again working great.

Thanks for the help you have given me so far, this is really important to me.

Later, Ray Parrish

#3 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:53 PM

Posted 13 March 2010 - 05:53 PM

That error message usually indicates a syntax error of some sort. Sounds like you got it sorted though.

EDIT: Javascript is no more particular than any other language. You are used to being able to cobble together HTML and CSS and making it work, and that just isn't the way programming languages work. A 13 year old can make a web page work, but they do not have the ability to do abstract thinking that real programming requires. HTML and CSS is not programming. Javascript is the real deal, and it it a very cool language.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users