JavaScript help please

Last post 07-24-2007 5:06 PM by XanaLyoko. 1 replies.

Sort Posts:

  • JavaScript help please

    07-24-2007, 12:57 PM
    • Loading...
    • XanaLyoko
    • Joined on 07-03-2007, 12:07 PM
    • Posts 68

     In my page I am using this javascript to get the value of the query string that is passed into my page:

        /* The code below grabs the value of the query string so that it can be used in the page *
         * To auto select the value of the first drop down menu.                                 *
         */
        // gets the current URL to get the query string
        var url = window.location.toString();
        
        //get the parameters using regular expressions
        url.match(/\?(.+)$/);
        var params = RegExp.$1;
        
        /* split up the query string and store in an *
         * associative array.                        *
         */
        var params = params.split("&");
        var queryStringList = {};
         
        for(var i=0;i<params.length;i++)
        {
            var tmp = params[i].split("=");
            queryStringList[tmp[0]] = unescape(tmp[1]);
        }
         
        // print all querystring in key value pairs
        for(var i in queryStringList)
        {
             var Qstring = queryStringList[i];
        }
        
        /* The code below takes the query string and will select the frist drop down menu based on the              *
         * QueryString that will be passed into the form.                                                           *
         */
        //alert(Qstring);//For debuging only.  Makes sure that it gets the proper value
        
        /* The code below will first make a reference to the parent system drop down menu so that it *
         * can access the drop down menu to compare the value of the query string to the values that *
         * are stored in the drop down menu.                                                         *
         */
    
        /* Loops through all of the items in the drop down menu and tehn compares them to the value  *
         * that is stored in Qstring.  If a match is found then it will preselect the value from that*
         * drop down menu.                                                                           *
         */
        for (iLoop = 0; iLoop < document.cq_request.ParentSystem.options.length; iLoop++)
        {    
            if (document.cq_request.ParentSystem.options[iLoop].value == Qstring)
            {
            /* A match is found.  Make this the selected option then populate the second drop down   *
             * and then exit the loop.                                                               *
             */
            document.cq_request.ParentSystem.options[iLoop].selected = true;
            
            /* This will populate the second drop down menu based on the value of Qstring by running *
             * through the SubSystemsDropDown function that is found in owner.js and putting passing *
             * the value of Qstring in place of the value of the first drop down menu.               *
             */
            SubSystemsDropDown(Qstring);
            break;
            }
        }    
    Now, the code is supposed to also select an option in the first drop down menu but it will alert me to the value of the query string at any time but it will not select an option from the first drop down menu.  Any help??
    The drop down list is populated by an asp.net SQL string.
    If history is to change let it change. If the world is to be destroyed so be it. If it is my fate to die ... I must simply laugh.
  • Re: JavaScript help please

    07-24-2007, 5:06 PM
    • Loading...
    • XanaLyoko
    • Joined on 07-03-2007, 12:07 PM
    • Posts 68

    I think that I have located the problem.  For some reason when I do alert(document.cq_request.ParenetSystem.options.length) it does not pop up an alert at all.

    Why would it not be getting the length of the drop down menu? and why would it not be putting up an alert?

    If history is to change let it change. If the world is to be destroyed so be it. If it is my fate to die ... I must simply laugh.
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter