I am encountering odd behavior when I include scriptaculous libraries
on a page where I have done custom HTTP requests (AJAX).

Please view this screenshot: 
https://mywebspace.wisc.edu/ahoffmann/pub/autocompleter_bug.jpg

When the user selects a Project, I generate a list of teams in a drop
down for that project to select from. If I include scriptaculous
libraries on this page, bizarre code gets placed in the drop-down. If
I take out the libraries, it works correctly.

The HTTP request I am doing is simple, and I am using a structure I
found at w3schools.com. The list of teams is returned as a delimited
file. The delimiter is ;; which may be the problem. Can someone look
at my Javascript and suggest an error that would cause it to conflict
with the scriptaculous libraries?

Thank you very much!

Coyote Hoffmann
University of Wisconsin

======= BEGIN JAVASCRIPT CODE ======

function getTeams() {

    var myXMLHTTP;
    var project = document.getElementById("project").value;

    if ( project != "xxx" ) {

        // Enable user box
        document.getElementById("user").disabled = false;

        // Set autocomplete box project number
        auto_project = project;

        try {
            // Firefox, Opera 8.0+, Safari
            myXMLHTTP=new XMLHttpRequest();
        } catch (e) {
            // Internet Explorer
            try {
                myXMLHTTP=new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    myXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    return false;
                }
            }
        }

        myXMLHTTP.onreadystatechange=function() {
            if ( myXMLHTTP.readyState == 4 ) {

                document.getElementById("team").options.length = 0;
                document.getElementById("team").options[0] = new Option
( "- All Teams -", "*", true, true );

                var response = new String( myXMLHTTP.responseText );
                alert(response);
                var responseArr = new Array();
                responseArr = response.split( ";;" );

                var j = 1;
                for ( var i in responseArr ) {
                    if ( responseArr[i] != "" ) {
                        var teamStr = new String( responseArr[i] );
                        var teamArr = teamStr.split( ";" );
                        var teamId = teamArr[0];
                        var teamName = teamArr[1];
                        document.getElementById("team").options[j] =
new Option( teamName, teamId, false, false );
                    }
                    j++;
                }

                document.getElementById("team").disabled = false;
            }
        }

        myXMLHTTP.open("GET","ajax_teams_from_project.php?project=" +
project, true);
        myXMLHTTP.send( null );

    } else {
        document.getElementById("team").disabled = true;
        document.getElementById("team").options.length = 0;
        document.getElementById("team").options[0] = new Option( "-
Select Team -", "xxx", true, true );

        // Disable user box
        document.getElementById("user").disabled = true;
        document.getElementById("user").value = "";
        document.getElementById("user_id").value = "";
        auto_project = null;
    }

}

====== END JAVASCRIPT CODE ======

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to