In the JS in your HTML page that has the eventhandlers you should have:
then in the eventhandler for SelectCal, pass in form and url:
call = SelectCal(form, url)
and for SwitchCal: call = SwitchCal(url)
then see changes to the functions below:
var request = null;
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
if (request == null)
alert("Error creating request object!");
function SwitchCals(url) {
var url = "switchcals.php";
request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
}
function updatePage() {
if (request.readyState == 4) {
var newCal = request.responseText;
document.getElementById("gcal").innerHTML = newCal;
}
}
function SelectCal(form, url) {
calItem = form.calendars.selectedIndex;
calNumber = form.calendars.options[calItem].value;
alert(calNumber);
url = "switchcals.php?calendars=" + calNumber;
alert(url);
}