Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to hide Web Part between certain dates-SharePoint 2010

Status
Not open for further replies.

cutum

Technical User
Sep 25, 2007
8
US
I need to make a web part in(SharePoint 2010) visible to users during a certain date range. My attempt is to use Java to do so, however, the code doesn't seem to work. I know the function works as I've successfully implemented it using and "on click" function with a button. That said, I would like to hide it using Java. Please advise if another solution is more viable or if something is wrong with my JavaScript. Thanks

Here's my Java:

<!--DOCTYPE html--><script>
var d = new Date();
var n = d.getDate();
var p = d.getMonth();

if ((d.getMonth() >= 2 && <= 3))
function myFunction() {

$('#MSOZoneCell_WebPartWPQ2').hide();
} </script>
 
UPDATE:

I am trying to hide a sharepoint calendar for most of the year. I only want it visible for a month or two. I'm attaching the code that I have been working on. The onclick button logic works fine and hides the calendar as I want, however, the "function hidepart1 "line after I display the popup after 3 seconds does not execute. I added the 3 second delay and popup just to see if it was making it down to that point. I do not know why the function hidepart1 will not execute.
I know I need to add additional code to my if statement to show the calendar when I need it.

<script>

var d = new Date();
var n = d.getDate();
var p = d.getMonth();

if (d.getMonth() >= 6 ) {

setTimeout(function() { alert(d.getMonth()); }, 3000);

function hidepart1() {
document.getElementById("MSOZoneCell_WebPartWPQ2").style.display = "none";} }

</script>

<a id="myLink" onclick="hidepart1();return false;" href="#">Click here to hide calendar</a>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top