I found a very simple snippet that I can add to a CEWP that changes the view in a calendar web part from Day, Week and Month. This is for an external facing SharePoint site and the ribbon will not be available.
<div style="float:right">
<div style="float:left; padding-right:10px;">
<a onclick="javascript:MoveView('day');" href="#">Day View</a>
</div>
<div style="float:left; padding-right:10px;">
<a onclick="javascript:MoveView('week');" href="#">Week View</a>
</div>
<div style="float:left; padding-right:10px;">
<a onclick="javascript:MoveView('month');" href="#">Month View</a>
</div>
</div>
This works great until I add more calendars on my page. My snippet only works for the first calendar that was added and not the other calendar web parts.
After some searching, I figured out how to reference the specific calendar web part I wanted to change by using .getElementById using javascript. I tested by using the following funtion to hide the web part, this ensured that I was able to reference a specific web part.
<script language='javascript' type='text/javascript'>
function myFunction()
{
document.getElementById("MSOZoneCell_WebPartWPQ6").style.display='none';
}
</script>
<input type="button" onclick="myFunction()" value="Show alert box" />
Again this worked just fine, however I am at a loss on how to combine the two to make everything work together.
I plan to use two or maybe more different calendar web parts, each with it's own CEWP above it that will contain the javascript to change the view.
Any help will be greatly appreciated.