jQuery to look up a list column in another SharePoint 2007 list and plug value in on change?
I have a page with a form in SP 2007. I've added a dataview to another list to that page and hidden it using a DIV tag. That dataview shows up as a table under a div with ID="WebPartWP
Q3"
, but I don't see any ID on the table itself. The dataview table looks like this. 3 columns (Title, Subject, BodyPrefix), with 2 rows of data:
<table TOPLEVEL border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top"><div WebPartID="00000000-0000-0000-0000-000000000000" HasPers="true" id="WebPartWPQ3" width="100%" OnlyForMePart="true" allowDelete="false" style="" ><table id="issuetbl" border="0" width="100%" cellpadding="2" cellspacing="0" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"><tr valign="top"><th class="ms-vh" nowrap>Title</th><th class="ms-vh" nowrap>Subject</th><th class="ms-vh" nowrap>BodyPrefix</th></tr><tr class="ms-alternating"><td class="ms-vb">transcription error
#1</td><td class="ms-vb">subject for transciption error 1</td><td class="ms-vb"><div>prefex for transcription error 1</div></td></tr><tr><td class="ms-vb"> transcription error #2 </td><td class="ms-vb">SUBJECT FOR TRANSCRIPTION ERROR #2</td><td class="ms-vb"><div>BODY PREFIX 2222
</div></td></tr></table></div></td> </tr> </table>
Does anybody have a jquery function that returns a column cell value (BodyPrefix here) given the first Title column match?
So , given "transcription error #2" return "BODY PREFIX 2222"
I started with this.. but not getting anything back in xx.
$('#issuetbl tr').each(function() { var xx = $(this).find开发者_开发知识库(".BodyPrefixCell").html(); }
nevermind.. i got it. Had to add an id to my table.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$('select[title$=Issue Type]').change(function(){
var issue = $('select[title$=Issue Type] :selected').text();
var prefix = $('#issuetbl td:contains('+ issue + ')').siblings().find('div').html();
$('textarea[title$=Message]').val(prefix);
});
</script>
精彩评论