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

Help




Back to top









