BleepingComputer.com: function is not defined error.

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

function is not defined error.

#1 User is offline   Ray Parrish 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 91
  • Joined: 30-October 08
  • Gender:Male
  • Location:Cottage Grove, Oregon

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

This post has been edited by Ray Parrish: 13 March 2010 - 01:59 PM


#2 User is offline   Ray Parrish 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 91
  • Joined: 30-October 08
  • Gender:Male
  • Location:Cottage Grove, Oregon

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 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,604
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

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.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users