I had a question on my recent article over at EndUserSharePoint.com entitled A jQuery Library for SharePoint Web Services (WSS 3.0 and MOSS): Real World Example – Part 1. The question was about the SPDisplayRelatedInfo function, and while I was setting things up to see if I had a bug, I found that there were some interesting ways you could use the SPDisplayRelatedInfo function that I hadn’t considered.
I added a Single line of text column to my old standby Sales Opportunities list and called it StateID. In my EditFormCustom.aspx, I added this call to SPDisplayRelatedInfo:
$().SPServices.SPDisplayRelatedInfo({
columnName: "StateID",
relatedList: "States",
relatedListColumn: "ID",
relatedColumns: ["ID", "Title"],
displayFormat: "table"
});
The States list is one of the lists I use in testing SPCascadeDropdowns, and it has these columns: State (the original Title column) and State Abbreviation. Now, when I typed digits into the StateID column, I got real-time results from the SPDisplayRelatedInfo function as the digits matched the ID of the State item. Cool!
So if I started out with the column empty, I saw:

then when I typed 1:

then when I typed 2:

This also worked if the StateID column was a Number column. Looking through the code, there was no reason this shouldn’t work, it’s just not the use I had intended.
So then I thought, well what if I wanted to match as I type the State? I switched the function call to this:
$().SPServices.SPDisplayRelatedInfo({
columnName: "StateID",
relatedList: "States",
relatedListColumn: "Title",
relatedColumns: ["ID", "Title", "State_x0020_Abbreviation"],
displayFormat: "table"
});
Then when I typed Massachusetts, I saw:

Hmm, that can’t be right. I went and checked the States list, and sure enough, I had some junk test data in there that I had forgotten about. Even cooler! The SPDisplayRelatedInfo function essentially acts like an as-you-type reference lookup!
These examples aren’t exactly what you’d be doing in the real world, but think about the situation where you had a product code that could be 1-5 digits or numbers or something where you wanted to let the user type instead of dealing with a dropdown. If you come up with another interesting use, let me know about it.
It’s always nice to find out that code you’ve written is *more* useful than you thought (as opposed to the dreaded less useful situation).