This project has moved and is read-only. For the latest updates, please go here.

jquery not firing when there are more items

Apr 27, 2010 at 5:48 PM


I have a lookup column in my main list.I am using GetListItems operation to get the items from the lookup list and populates the main list columns. This works fine when I have few items in the lookup list like 5-10. Now i added around 253 items in the lookup list, and when I change the drop down value jquery does not fire anymore. I am not sure what is going on, I checked with the U2U CAML query tool if the lookup list is good with the CAML queries and it brings up data there. I also indexed the column in the lookup list. Nothing seems to work. Any help is appreciated.

here is the script

    function getZRows(rXML)
    var rows; 
    var itemCount = $(rXML).find("rs\\:data").attr("ItemCount"); 
    if (rXML.getElementsByTagName("z:row").length == 0 && itemCount == undefined)
         rows = rXML.getElementsByTagNameNS("*", "row"); 
          rows = rXML.getElementsByTagName("z:row"); 
    return rows; 

//  Department column assignments
    var dept = $("select[title$='Department']");
    var deptNo = $("input[title$='No']");
    var location = $("input[title$='Location']");
    var division = $("input[title$='Division']");

 //department assignment
   operation:        'GetListItems',
   listName:         'RR - Department List',
   async:            false,
   CAMLRowLimit:     1,
   CAMLQueryOptions: '<QueryOptions/>',
   CAMLViewFields:   "<ViewFields><FieldRef Name='Dept_x0020_Code'/><FieldRef Name='Location'/><FieldRef Name='Division'/><\/ViewFields>",
   CAMLQuery:        "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + $(dept).find(":selected").text() + "<\/Value><\/Eq><\/Where><\/Query>",
   completefunc: function(xData, Status) {
      var out = getZRows(xData.responseXML);
                           if ($(out).attr("ows_Location")==null)
                           if ($(out).attr("ows_Dept_x0020_Code")==null)
                           if ($(out).attr("ows_Division") == null)


Apr 27, 2010 at 7:15 PM

SharePoint renders dropdowns with 20+ items differently than when there are fewer than 20 values.  This is something I handle for you in SPCascadeDropdowns, but if you are building something, you'll need to handle it in your code as well.

It's not clear to me exactly what you're trying to do above, but check this blog post which explains how to work with the z:row namespace reliably:

You may want to use $().SPServices.SPDisplayRelatedInfo and then grab the values from there rather than writing this from scratch.


Apr 27, 2010 at 8:22 PM

Hi M,

I am very new to SPServices and jquery, please bear with me.

I have a list which contains all the Departments( has 4 columns). In my main list called Records I have a lookup field for department from the deparments list. Now on change of the department selection I want to populate 3 fields on the Records list and that is what I was trying to do in my script.

With the SPDisplayRelatedInfo, it does not allow any assigment of values to other columns, at least that is how I understand it. PLease correct me if I am wrong

With the SPCascadeDropdowns, it seems to asssign values to other dropdowns. I even thought maybe i can specify multiple columns in the childcolumn but I could not.

Please advise.




Apr 27, 2010 at 8:52 PM


Thanks for the additional info.  I would actually discourage you from storing the additional 3 columns in the Records list.  Instead, you should do a "join" in a DVWP whenever you need the details.

That said, you're right that SPDisplayRelatedInfo doesn't populate any other columns. However, by using the completefunc, you can grab the values out of the results and populate.  It would give you the ability to display the 4 columns of data so that the user is sure they have selected the right value.


Apr 27, 2010 at 9:36 PM

Hi M,

Thank you very much for taking the time. How can i grab the values out of the results and populate with regards to SPDIplayRelatedInfo?

Apr 27, 2010 at 9:41 PM

That's where you'd need to write your custom jQuery, as you started to in the first post above.

Dropdowns with <20 options are plain old selects, and dropdowns with 20+ options are input/select hybrids.  You could look at the SPCascadeDropdowns to see how I handle this.  There is a function called dropdownCtl which will show you how I find the columns in the page.