Please bear with me as I am still learning sharepoint and web technologies in general.
I have put a rotator on my sharepoint page using the easy to use script generated by http://usermanagedsolutions.com/SharePoint-User-Toolkit/Pages/Image-Rotator.aspx. I have the code below saved to a .txt file and I am linking to it in a CEWP. I am trying to add a caption under the image using the title field from picture library.
I thought I could just add table under the image and use getElementByID to replace the contents of the tag with variable that already has the title information in it, but my understanding must be off because it's not working. I am able to see the images, but the <td> remains empty.
I added in the table and this line document.getElementById("rotator_title").innerText=pAlt;hoping it would replace the <td> tag with value saved in pALT which I was hoping would be the item title. Here is my code. Any suggestions or am I way off?
<div class="IR-container">
<a>
<img id="IR-img" border="0" height="153px" width="310px" src="/_layouts/images/blank.GIF"/>
<span />
</a>
</div>
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr>
<td id="rotator_title"></td>
</tr>
</table>
<script type="text/javascript">
/* Image Rotator - v 2.0 * Copyright (c) 2008-2010 Christophe Humbert *http://www.pathtosharepoint.com */
(function(){
var sec = 15;
var d = new Date();
var plURL ="/_vti_bin/owssvr.dll?Cmd=Display&XMLDATA=TRUE&List={xxxx-xxxx-xxx-}&View={xxx}&Source=xxxx="+d.getTime();
var IRi = document.getElementById("IR-img");
IRi.removeAttribute("id");
var i = -1;
function DisplayPicture(IRi,Items){i=Math.floor(Math.random()*Items.length);
var pURL ="/"+Items[i].getAttribute("ows_RequiredField");
pURL =pURL.replace(/\.([^\.]+)$/, "_$1") + ".jpg";
pURL =pURL.replace(/\/([^\/]+)$/,"/_w/"+"$1");
IRi.src =pURL;
var pAlt =Items[i].getAttribute("ows_NameOrTitle");
var pDesc ='';
IRi.alt =pAlt;
IRi.nextSibling.innerHTML=pDesc;
document.getElementById("rotator_title").innerText=pAlt;
}
try {var x=new XMLHttpRequest();}
catch(e){try{var x=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{var x=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){IR.innerHTML="Your browser does not support AJAX requests.";}}}x.onreadystatechange=function(){if (x.readyState==4){if (x.status==200){var xml=x.responseXML;
var Items= xml.getElementsByTagNameNS)?xml.getElementsByTagNameNS("*","row"):xml.getElementsByTagName("z\:row");
DisplayPicture(IRi,Items);
if (sec>0) {var Refresh=function(d,i,t){setInterval(function(){DisplayPicture(d,i);},t*1000);};Refresh(IRi,Items,sec);}}else{alert("Problem retrieving XML data");}}};x.open("GET",plURL,true);x.send(null);})();
</script>