<script language="javascript" type="text/javascript">
$(document).ready(function() { //-----------SPSERVICES GET ALL LIST ITEMS FROM THE LIST
var htmlTable = '<table>';
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Thisweek",
CAMLRowLimit: 10,
CAMLViewFields: "<ViewFields>" +
"<FieldRef Name='Title'></FieldRef>" +
"<FieldRef Name='Created'></FieldRef>" +
"</ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() { //--------FIND EACH RECORD FROM THE LIST
var id = $(this).attr("ows_ID");
htmlTable += "<tr>" +
"<td>" +
"<a href=\"javascript:\" + onclick=\"OpenModalDialog('" + id + "')\">" +
"<img src='/_layouts/images/StopHS.png' width='11' height='11'/>" + " " +
$(this).attr("ows_Title").substr(0,50) +
"</a>" +
SPConvertDate($(this).attr("ows_Created")) +
"... " +
"</td>" +
"</tr>";
})
htmlTable += "</table>";
$("#htmlTableOutput").html(htmlTable);
}
});
});
//---------------------------------------------
//-------- THIS IS THE MODEL DIALOGUE FUNCTION
//---------------------------------------------
function OpenModalDialog(id) {
var options = {
url: "/Lists/Thisweek/DispForm.aspx?ID=" + id,
title: "This Week ",
width: 800,
height: 1000,
dialogReturnValueCallback: DialogAnnouncementCallback
};
SP.UI.ModalDialog.showModalDialog(options);
}
function DialogAnnouncementCallback(dialogResult, returnValue) { }
//---------------------------------------------
//-------- CONVERTS DATE TO MM/DD/YYYY FORMAT
//---------------------------------------------
function SPConvertDate(t){
var d = new Date(t.substr(0,4), parseInt(t.substr(5,2)) - 1, t.substr(8,2), t.substr(11,2), t.substr(14,2), t.substr(17,2));
var month = ((d.getMonth()+1) < 10) ? "0" + (d.getMonth()+1) : (d.getMonth()+1);
var date = (d.getDate() < 10) ? "0" + d.getDate() : d.getDate();
var minutes = (d.getMinutes() < 10) ? "0" + d.getMinutes() : d.getMinutes();
var amPm = (d.getHours() < 12) ? "am" : "pm";
return " [" + month + "/" + date + "/" + d.getFullYear() + "]";
}
</script>
<div id="htmlTableOutput"></div>
↧
New Post: SPServices 2013.01 - Test
↧