Normally I can find what I need here without having to post myself, but I'm stumped with this one. Go easy on me!
I have some XSLT that pulls a number of user records staff name (SharePoint 2010). I need to pass a javascript function the staff name so it can use it to create a URL for a staff image, and pass the value back to replace the image src for each of the images.
Here's some of the code I'm trying to put together:
function loadStaffPic(staffName) {
/* Code to use staffName to retrieve loginID from
SharePoint OM goes here and returns the variable loginID */
var filename = loginID.replace("\\","_");
var picURL = "http://www.mywebsite.com/images/" + filename + ".png";
document.getElementById("StaffPic").src = picURL;
}
<xsl:template>
<xsl:template name="dvt_1.rowview">
<img id="StaffPic{generate-id()}" onload="loadStaffPic({@Staff_x0020_Name})" src="placeholder.png" alt="{@Staff_x0020_Name}" />
</xsl:template>
Can I use onload in the img tag like this? And if so, how can I target the image with the generated ID?
I'm assuming some kind of a loop is required...
By the way, if there is a better jQuery option that would be even better.
If I've not put enough information please let me know.
Chris