Hi Thanks for this.
I have tried putting the code in but it returns nothing.
The list has a field called CreateDate which is just a date field set to default value of today.
From Marc's original example I created this script which has an animated button on it whoch launches a newform.aspx and then the code for counting the total number of items and placing it in a table.
I have tried putting the code in but it returns nothing.
The list has a field called CreateDate which is just a date field set to default value of today.
From Marc's original example I created this script which has an animated button on it whoch launches a newform.aspx and then the code for counting the total number of items and placing it in a table.
<html>
<table>
<tr>
<td>
<a href="/lists/opportunities/newform.aspx?source=/" onMouseOver="return changeImage()" onMouseOut= "return changeImageBack()" onMouseDown="return handleMDown()"
onMouseUp="return handleMUp()"><img name="jsbutton" src="/AnimFrog/AnimInitial.jpg" width="110" height="260" border="0"
alt="javascript button"></a>
<script language="JavaScript">
upImage = new Image();
upImage.src = "/AnimFrog/AnimHover.jpg";
downImage = new Image();
downImage.src = "/AnimFrog/AnimClick.jpg"
normalImage = new Image();
normalImage.src = "/AnimFrog/AnimInitial.jpg";
function changeImage()
{
document.images["jsbutton"].src= upImage.src;
return true;
}
function changeImageBack()
{
document.images["jsbutton"].src = normalImage.src;
return true;
}
function handleMDown()
{
document.images["jsbutton"].src = downImage.src;
return true;
}
function handleMUp()
{
changeImage();
return true;
}
</script>
</td>
<td>
Total number of items:<span id="frogItemCount"></span>
</td>
<td>
<script type="text/javascript" src="/scripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.SPServices-2014.01.min.js"></script>
<script language="JavaScript">
$().SPServices({
operation: "GetListItems",
listName: "Opportunities",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).find("rs\\:data").each(function() {
itemCount = $(this).attr("ItemCount");
});
}
});
$("#frogItemCount").html(itemCount);
</script>
</td>
</tr>
</table>
So then I tried to alter the code with the piece above about getting the date but it doesn't return any data at all. Am I missing something obvious. The MOSS site is set to UK regional settings.<html>
<table>
<tr>
<td>
<a href="/lists/opportunities/newform.aspx?source=/" onMouseOver="return changeImage()" onMouseOut= "return changeImageBack()" onMouseDown="return handleMDown()"
onMouseUp="return handleMUp()"><img name="jsbutton" src="/AnimFrog/AnimInitial.jpg" width="110" height="260" border="0"
alt="javascript button"></a>
<script language="JavaScript">
upImage = new Image();
upImage.src = "/AnimFrog/AnimHover.jpg";
downImage = new Image();
downImage.src = "/AnimFrog/AnimClick.jpg"
normalImage = new Image();
normalImage.src = "/AnimFrog/AnimInitial.jpg";
function changeImage()
{
document.images["jsbutton"].src= upImage.src;
return true;
}
function changeImageBack()
{
document.images["jsbutton"].src = normalImage.src;
return true;
}
function handleMDown()
{
document.images["jsbutton"].src = downImage.src;
return true;
}
function handleMUp()
{
changeImage();
return true;
}
</script>
</td>
<td>
Total number of items:<span id="frogItemCount"></span>
</td>
<td>
<script type="text/javascript" src="/scripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.SPServices-2014.01.min.js"></script>
<script language="JavaScript">
{ var itemCount;
var daysFromSunday = (new Date()).getDay(),
dateOffset = (
daysFromSunday > 0 ? " OffsetDays='-" + daysFromSunday + "'" : ""
),
query;
var daysToSunday = 7 - daysFromSunday;
var query = "<Query>" +
"<Where>" +
"<And>" +
"<Geq>" +
"<FieldRef Name='CreateDate' />" +
"<Value Type='DateTime'>" +
"<Today OffsetDays='-" + daysFromSunday + "'/>" +
"</Value>" +
"</Geq>" +
"<Leq>" +
"<FieldRef Name='CreateDate' />" +
"<Value Type='DateTime'>" +
"<Today OffsetDays='" + daysToSunday + "'/>" +
"</Value>" +
"</Leq>" +
"</And>" +
"</Where>" +
"</Query>";
$().SPServices({
operation: "GetListItems",
listName: "Opportunities",
async: false,
completefunc: function(xData, Status) {
itemCount = $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount");
}
});
});
$("#frogItemCount").html(itemCount);
</script>
</td>
</tr>
</table>