What it does:
- When the page loads the buttons are changed to will wait for a calendar entry to be made before submitting the form.
How to do it:
- Make your Calendar and Database applications, add at least a text and date element to your Database.
- Note the folder id and event type from the Calendar. Note the date and button element ids on the form.
- Customize the following sample script accordingly.
- Add the script to a rich text element in the form.
<script>
function init() {
if(document.location.href.indexOf("MainWindow.po")<0 || document.location.href.indexOf("formHandle")>0 ){
return;
}
document.getElementById("add").type="button";
document.getElementById("addAnother").type="button";
top.noodle.cbc.addEventListener(document.getElementById("add"), 'click', doit);
top.noodle.cbc.addEventListener(document.getElementById("addAnother"), 'click', doit);
}
function doit() {
document.getElementById("lowerButtonBar").style.display="none";
var folder="256272"
var evetnTypeID="3511";
var title="Training "+top.noodle.headWindow().document.getElementById("currentUserName").innerHTML;
var day=document.getElementById("day_220063").value;
var month=document.getElementById("month_220063").value;
var year=document.getElementById("year_220063").value;
month=parseInt(month)-1;
var vars="";
vars+="folder="+folder;
vars+="&eventid=new";
vars+="&addedRecipients=";
vars+="&title="+title;
vars+="&isAllDay=";
vars+="&isPrivate=";
vars+="&eventType="+evetnTypeID;
vars+="&quickSave=Quick Save";
vars+="&repeat=";
vars+="&eventColorName=LightBlue";
vars+="&eventColor=#add8e6";
vars+="&save=Save";
vars+="&selMonth="+month;
vars+="&selDay="+day;
vars+="&selYear="+year;
vars+="&startHour=9";
vars+="&startMinute=00";
vars+="&am_pm=am";
vars+="&durationMonth="+month;
vars+="&durationDay="+day;
vars+="&durationYear="+year;
vars+="&durationHour=5";
vars+="&durationMinute=00";
vars+="&duration_am_pm=pm";
vars+="&TimeZone=6";
vars+="&eventLocation=";
vars+="&groupsAndUsersList=";
vars+="&addedGroupsAndUsers=";
vars+="&endAfterN=1";
top.noodle.ajax.post("/calendar/HandleEventView.po", vars, handle_doit, []);
return false;
}
function handle_doit(xml, txt, array) {
top.noodle.cbc.removeEventListener(document.getElementById('add'), 'click', doit);
top.noodle.cbc.removeEventListener(document.getElementById('addAnother'), 'click', doit);
document.getElementById("lowerButtonBar").style.display="block";
document.mainform.submit();
}
window.onload = init;
</script>