Calling a function from a function (non-recursive functions)


It is a very silly thing going on here.

I am calling a function from a function and it doesn’t work. Unfortunately for reason my firefox is not working on my computer, otherwise using firebug, I would have debugged. can someone take a look at this issue please?

<script type="text/javascript">

            function ClearLabelControls()
                 var allLabels = document.getElementById("LabelPortfolioCounts").getElementsByTagName("span");

                var i = 0;
                var len = allLabels.length;

                for (i; i < len; i++) {

                    allLabels[i].innerHTML = "";


            function PerformChecks() {

                //first clear all controls


                var vartextboxEOM = document.getElementById('<%= TextBoxPeriod.ClientID%>').value;

                var vardropdownEOM = document.getElementById('<%= DropDownListEOMDates.ClientID %>');

The i looks very lonely as the initialisation of for (i; i < len; i++). Maybe it works but I’ve never seen it (and I’m pretty sure it won’t work but without wanting to look at the official spec I can’t be 100% sure).

Instead it should be for (i[B]=0[/B]; i < len; i++)

Then you can also rewrite

var i = 0;
var len = allLabels.length;


var i, len = allLabels.length;

because you don’t need to initialise i outside the loop, just declaring it is enough.

There doesn’t seem to be anything wrong with the code from what we’ve seen of it yet.

Making for (i=0; i < len; i++) does the trick.

thanks folks