[thelist] JS Code Execution Ends Prematurely with no error....

Anthony Baratta anthony at baratta.com
Thu Mar 23 18:00:14 CST 2006


Howdy...

I'm working on a "psuedo-object" within Javascript that uses AJAX to populate several drop down menus based upon the selection of a primary drop down.

For some reason the code stops executing after a specific point but does not throw an error. I can't show the full page or code since it's on an intranet - but here's a few key lines that I hope will be helpful.

Below look for the two alert calls:

            alert("options start (" + this.sID + ")");
            alert("options end (" + this.sID + ")");

The first one executes fine.The second never does. The drop downs are populated correctly but the code does not execute further than the for next look betwen the two alerts. The for/next loop is the last thing executed in "fillSelect".

Any ideas? If you need more info, let me know.

// Build new JS select object
                var objFltSelect = new objSelect('fltID');
                    objFltSelect.rebuildSelect(sValue);

// JS Select Object Code
	function objSelect(selectID)
	{
	    this.sID = selectID;
	    this.oSelect = document.getElementById(selectID);
	    
	    this.rebuildSelect = function (sValue)
	    {
            this.oSelect.disabled = false;
            this.oSelect.options.length = 0;
            this.appendSelect("*", this.selectMessage(this.sID));
            this.oSelect.disabled = true;
            
	        if (sValue.trim() != "")
            {
		        this.sQueryString = "?a=select" + escape(this.sID) + "&v=" + escape(sValue);
		        this.cObj = WAMU.util.Connect.asyncRequest('GET', './SelectRep_Ajax.asp' + this.sQueryString, this.callBack, null);
            }
	    };
        
        this.fillSelect = function(sResponseText)
        {
            this.aValues = sResponseText.split("||");
            this.oSelect.disabled = false;
            this.appendSelect("*", "--------------------");
            
            // This alert executes
            alert("options start (" + this.sID + ")");
            for (var x = 0; x <= this.aValues.length; x++)
            {
                this.aOptions = this.aValues[x].split("??");
                this.appendSelect(this.aOptions[0], this.aOptions[1]);
            };
            // This alert does not execute
            alert("options end (" + this.sID + ")");
        };
        
        this.appendSelect = function(sValue, sText)
        {
            this.oOption = document.createElement("option");
            this.oOption.value = sValue;
            this.oOption.text = sText;
            
            if (ie)
            {
                this.oSelect.add(this.oOption);
            } else {
                this.oSelect.add(this.oOption, null);
            };
        };
        
	    this.responseSuccess = function(o) 
	    {
	        if (o.responseText.trim() != "")
	        {
                this.fillSelect(o.responseText.trim());
	        }
		    //o.responseText
		    //o.argument
	    };
	    this.responseFailure = function(o)
	    {
	        document.getElementById("ErrorMsg").innerHTML = o.statusText;
	        this.oSelect.disabled = true;
		    //o.statusText
	    };
    	this.callBack =
	    {
    		success : this.responseSuccess,
	    	failure : this.responseFailure,
	    	scope: this,
		    argument: "dummy value"
    	};

	    this.selectMessage = function() 
	    {
	        this.message = "";
	        switch(this.sID)
	        {
	            case "locID":
	                this.message = "-- Select a Location --";
	                break;
	            case "mgrID":
	                this.message = "-- Select a Manager --";
	                break;
	            case "fltID":
	                this.message = "-- Reviewing Organization --";
	                break;
	        }
	        return this.message;
	    };
	    this.defaultSelect = function()
	    {
	        this.sIndex = 0;
	        switch(this.sID)
	        {
	            case "fltID":
	                this.sIndex = 2;
	                break;
	        }
	        return this.sIndex;
	    }
	}



More information about the thelist mailing list