Javascript Code on markmaybewrong
The following code is used to unhide/hide the picks in our database. It does so by toggling the display property of the element between "none" ans "block":
function hideshow(elID) {
if (document.getElementById(elID).style.display == 'block') {
document.getElementById(elID).style.display = 'none';
} else {
document.getElementById(elID).style.display = 'block';
}
}
The following code use used to change pictures in the "youmaybewrong" contest. It does so my changing the "src" of the given image.
function changePic(game,pick) {
document.getElementById(game).src = "http://www.nd.edu/~tszarek/markmaybewrong/" + pick + ".jpg";
}
The following code is used to populate the Handle and Address fields from the returning handle select lest for the "youmaybewrong" contest. If does so my setting the value of the "TeamName" field to the text of the select list (less the link address) and the "Address" field to the value of the select list.
function populateTeamName() {
var s = document.youmaybewrong.retTeamName[document.youmaybewrong.retTeamName.selectedIndex].text.replace(" ("+document.youmaybewrong.retTeamName.value+")","");
document.youmaybewrong.TeamName.value = s;
document.youmaybewrong.Address.value = document.youmaybewrong.retTeamName.value
}
The following code is used to verify and submit the picks for the "youmaybewrong" contest. It does so my ensuring ten radio buttons are selected (a pick is made for each of the ten games), the "TeamName" field is not blank, and the "eMail" field containg an address with an "@" followed by a ".". The picks are then complied and directed to the website to save the picks.
function verifyForm() {
var elements = document.getElementsByTagName("input");
var count = 0;
var why = "";
var gamepicks = "";
if (document.youmaybewrong.TeamName.value == "") {
why = why + "\n You have not entered a team name."
}
for (i=0; i
if (elements[i].type == "radio") {
if (elements[i].checked == true) {
count = count + 1;
gamepicks = gamepicks + elements[i].value + ",";
}
}
}
if (count != 10) {
why = why + "\n You have not picked a winner in all the games.";
}
var atLoc = document.youmaybewrong.eMail.value.indexOf("@",0);
if ((atLoc == -1)|(document.youmaybewrong.eMail.value.indexOf(".",atLoc+1) == -1)) {
why = why + "\n E-mail is not valid";
}
if (why != "") {
alert ("Not so fast my friend!" + why);
} else {
window.location.href = "http://www.nd.edu/~tszarek/markmaybewrong/youmaybewrong.htm#" + document.youmaybewrong.TeamName.value + "," + document.youmaybewrong.Address.value + "," + document.youmaybewrong.eMail.value + "," + gamepicks
}
}
