J
Jimmy Smits
Hi
I have been playing with some JS that I cut from another page. It is a NCAA
tournament bracket. When the user clicks on the submit button it sends the
predictions to a db I have created.
I got all of this to work fine. The problem I have now is that the
predictions are sent to my DB as numbers for example Kentucky = 0 so anytime
the user selects Kentucky it sends a zero.
For the life of me I cant find where in the script I can change this so that
it submits "kentucky" rather than a zero.
Here is the code:
<script language=JavaScript>
<!--
function InitWindow()
{document.PickEntry.reset();}
IE4 = document.all;
function oldAlert(mess) {
newAlert(" Entry Error",mess,3,0);
}
function newAlert(title,mess,icon,mods) {
(IE4) ? makeMsgBox(title,mess,icon,0,0,mods) : alert(mess);
}
function newConfirm(title,mess,icon,defbut,mods) {
if (IE4) {
icon = (icon==0) ? 0 : 2;
defbut = (defbut==0) ? 0 : 1;
retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
retVal = (retVal==6);
}
else {
retVal = confirm(mess);
}
return retVal;
}
function newPrompt(title,mess,def) {
retVal = (IE4) ? makeInputBox(title,mess,def) : prompt(mess,def);
if (retVal) {}
else {retVal = '';}
return retVal;
}
function WriteIt(id, text)
{if (document.layers){
var l = document[id];
if (!l.ol) {
var ol = l.ol = new Layer (l.clip.width, l);
ol.clip.width = l.clip.width;
ol.clip.height = l.clip.height;
ol.bgColor = l.bgColor;
l.visibility = 'hide';
ol.visibility = 'show';}
var ol = l.ol;
out = " ";
add = " ";
teamtext = "" + text;
while (teamtext.indexOf(out)>-1){
pos= teamtext.indexOf(out);
teamtext = "" + (teamtext.substring(0, pos) + add +
teamtext.substring((pos + out.length), teamtext.length));}
ol.document.open();
ol.document.write('<span class="oddrow">'+teamtext+'</span>');
ol.document.close();
ol.clip.width=l.clip.width=ol.document.width;
ol.clip.height=l.clip.height=ol.document.height;}
else if (document.all || document.getElementById) {
if (document.all)
document.all[id].innerText = text;
else {
var l = document.getElementById(id);
var r = document.createRange();
r.setStartAfter(l);
var docFrag = r.createContextualFragment(text);
while (l.hasChildNodes())
l.removeChild(l.firstChild);
l.appendChild(docFrag);}
}
}
function PickIt(pickid, teamid)
{var id="entry"+pickid;
var currpick = document.PickEntry.elements["PICK"+pickid].value;
if (pickid > 32){
teamid = document.PickEntry.elements["PICK"+teamid].value;
if (teamid == 64) {return;}
teamid++;}
if (currpick == teamid-1){return;};
var text=document.PickEntry.elements["TEAM"+teamid].value;
document.PickEntry.elements["PICK"+pickid].value = teamid-1;
WriteIt(id, text);
var nextround = pickid;
while (nextround != 63){
var nextroundpick =
document.PickEntry.elements["PICK"+nextgame[nextround]].value;
if (nextroundpick != 64){
if (nextroundpick == currpick){
if (nextroundpick != teamid-1){
document.PickEntry.elements["PICK"+nextgame[nextround]].value = teamid-1;
WriteIt("entry"+nextgame[nextround],text);
}
}
}
nextround = nextgame[nextround];}
}
var spacer=' ';
if(document.layers){
for(counter=2; counter <= 15; counter++)
{spacer=spacer+' '}
origWidth=innerWidth;
origHeight=innerHeight;
onresize=function(){
if(innerWidth!=origWidth||innerHeight!=origHeight)
location.reload()}
}
var nextgame = new Array(62);
nextgame[1] = nextgame[2] = 33;
nextgame[3] = nextgame[4] = 34;
nextgame[5] = nextgame[6] = 35;
nextgame[7] = nextgame[8] = 36;
nextgame[9] = nextgame[10] = 37;
nextgame[11] = nextgame[12] = 38;
nextgame[13] = nextgame[14] = 39;
nextgame[15] = nextgame[16] = 40;
nextgame[17] = nextgame[18] = 41;
nextgame[19] = nextgame[20] = 42;
nextgame[21] = nextgame[22] = 43;
nextgame[23] = nextgame[24] = 44;
nextgame[25] = nextgame[26] = 45;
nextgame[27] = nextgame[28] = 46;
nextgame[29] = nextgame[30] = 47;
nextgame[31] = nextgame[32] = 48;
nextgame[33] = nextgame[34] = 49;
nextgame[35] = nextgame[36] = 50;
nextgame[37] = nextgame[38] = 51;
nextgame[39] = nextgame[40] = 52;
nextgame[41] = nextgame[42] = 53;
nextgame[43] = nextgame[44] = 54;
nextgame[45] = nextgame[46] = 55;
nextgame[47] = nextgame[48] = 56;
nextgame[49] = nextgame[50] = 57;
nextgame[51] = nextgame[52] = 58;
nextgame[53] = nextgame[54] = 59;
nextgame[55] = nextgame[56] = 60;
nextgame[57] = nextgame[58] = 61;
nextgame[59] = nextgame[60] = 62;
nextgame[61] = nextgame[62] = 63;
function PlayerIDCheck()
{ var form = self.document.forms["PickEntry"];
if(form.PLAYERID.value=="")
{ oldAlert(" You must enter: Name Last,First.");
form.PLAYERID.focus();
return false;}
else { return true;}}
function PlayerInfo3Check()
{ var form = self.document.forms["PickEntry"];
if(form.PLAYERINFO3.value=="")
{ oldAlert(" You must enter: E-Mail Address.");
form.PLAYERINFO3.focus();
return false;}
else { return true;}}
function PlayerInfo3MailCheck()
{ var form = self.document.forms["PickEntry"];
if ((form.PLAYERINFO3.value == " ") ||(form.PLAYERINFO3.value.indexOf ('@',
0) == -1) ||(form.PLAYERINFO3.value.indexOf ('.', 0) == -1))
{ oldAlert(" You must enter a valid e-mail address for the E-Mail
Address.");
form.PLAYERINFO3.focus();
return false;}
else { return true;}
}
function TieBreakerPointsCheck()
{ var form = self.document.forms["PickEntry"];
if(form.TIEBREAKER.value=="")
{ oldAlert(" You must enter: Tie Breaker Points.");
form.TIEBREAKER.focus();
return false;}
else { return true;}}
function VerifyPick()
{var form = self.document.forms["PickEntry"];
var NoPickMade = 0;
for(counter=1; counter <= 63; counter++)
{ var GamePick = document.PickEntry.elements["PICK"+counter].value;
if (GamePick == 64) {NoPickMade++;}}
if(NoPickMade > 0){ oldAlert(" You must enter a selection for every game.");
return false;}
else { return true;}}
function VerifyPage() {
if (! PlayerIDCheck()) { return false;}
if (! PlayerInfo3Check()) { return false;}
if (! PlayerInfo3MailCheck()) { return false;}
if (! VerifyPick()) { return false;}
if (! TieBreakerPointsCheck()) { return false;}
return true;}
// -->
</script>
<script language=VBScript>
<!--
Function makeMsgBox(title, mess, icon, buts, defbut, mods)
butVal = buts + (icon * 16) + (defbut * 256) + (mods * 4096)
makeMsgBox = MsgBox(mess, butVal, title)
End Function
// -->
</script>
Thanks for reading
I have been playing with some JS that I cut from another page. It is a NCAA
tournament bracket. When the user clicks on the submit button it sends the
predictions to a db I have created.
I got all of this to work fine. The problem I have now is that the
predictions are sent to my DB as numbers for example Kentucky = 0 so anytime
the user selects Kentucky it sends a zero.
For the life of me I cant find where in the script I can change this so that
it submits "kentucky" rather than a zero.
Here is the code:
<script language=JavaScript>
<!--
function InitWindow()
{document.PickEntry.reset();}
IE4 = document.all;
function oldAlert(mess) {
newAlert(" Entry Error",mess,3,0);
}
function newAlert(title,mess,icon,mods) {
(IE4) ? makeMsgBox(title,mess,icon,0,0,mods) : alert(mess);
}
function newConfirm(title,mess,icon,defbut,mods) {
if (IE4) {
icon = (icon==0) ? 0 : 2;
defbut = (defbut==0) ? 0 : 1;
retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
retVal = (retVal==6);
}
else {
retVal = confirm(mess);
}
return retVal;
}
function newPrompt(title,mess,def) {
retVal = (IE4) ? makeInputBox(title,mess,def) : prompt(mess,def);
if (retVal) {}
else {retVal = '';}
return retVal;
}
function WriteIt(id, text)
{if (document.layers){
var l = document[id];
if (!l.ol) {
var ol = l.ol = new Layer (l.clip.width, l);
ol.clip.width = l.clip.width;
ol.clip.height = l.clip.height;
ol.bgColor = l.bgColor;
l.visibility = 'hide';
ol.visibility = 'show';}
var ol = l.ol;
out = " ";
add = " ";
teamtext = "" + text;
while (teamtext.indexOf(out)>-1){
pos= teamtext.indexOf(out);
teamtext = "" + (teamtext.substring(0, pos) + add +
teamtext.substring((pos + out.length), teamtext.length));}
ol.document.open();
ol.document.write('<span class="oddrow">'+teamtext+'</span>');
ol.document.close();
ol.clip.width=l.clip.width=ol.document.width;
ol.clip.height=l.clip.height=ol.document.height;}
else if (document.all || document.getElementById) {
if (document.all)
document.all[id].innerText = text;
else {
var l = document.getElementById(id);
var r = document.createRange();
r.setStartAfter(l);
var docFrag = r.createContextualFragment(text);
while (l.hasChildNodes())
l.removeChild(l.firstChild);
l.appendChild(docFrag);}
}
}
function PickIt(pickid, teamid)
{var id="entry"+pickid;
var currpick = document.PickEntry.elements["PICK"+pickid].value;
if (pickid > 32){
teamid = document.PickEntry.elements["PICK"+teamid].value;
if (teamid == 64) {return;}
teamid++;}
if (currpick == teamid-1){return;};
var text=document.PickEntry.elements["TEAM"+teamid].value;
document.PickEntry.elements["PICK"+pickid].value = teamid-1;
WriteIt(id, text);
var nextround = pickid;
while (nextround != 63){
var nextroundpick =
document.PickEntry.elements["PICK"+nextgame[nextround]].value;
if (nextroundpick != 64){
if (nextroundpick == currpick){
if (nextroundpick != teamid-1){
document.PickEntry.elements["PICK"+nextgame[nextround]].value = teamid-1;
WriteIt("entry"+nextgame[nextround],text);
}
}
}
nextround = nextgame[nextround];}
}
var spacer=' ';
if(document.layers){
for(counter=2; counter <= 15; counter++)
{spacer=spacer+' '}
origWidth=innerWidth;
origHeight=innerHeight;
onresize=function(){
if(innerWidth!=origWidth||innerHeight!=origHeight)
location.reload()}
}
var nextgame = new Array(62);
nextgame[1] = nextgame[2] = 33;
nextgame[3] = nextgame[4] = 34;
nextgame[5] = nextgame[6] = 35;
nextgame[7] = nextgame[8] = 36;
nextgame[9] = nextgame[10] = 37;
nextgame[11] = nextgame[12] = 38;
nextgame[13] = nextgame[14] = 39;
nextgame[15] = nextgame[16] = 40;
nextgame[17] = nextgame[18] = 41;
nextgame[19] = nextgame[20] = 42;
nextgame[21] = nextgame[22] = 43;
nextgame[23] = nextgame[24] = 44;
nextgame[25] = nextgame[26] = 45;
nextgame[27] = nextgame[28] = 46;
nextgame[29] = nextgame[30] = 47;
nextgame[31] = nextgame[32] = 48;
nextgame[33] = nextgame[34] = 49;
nextgame[35] = nextgame[36] = 50;
nextgame[37] = nextgame[38] = 51;
nextgame[39] = nextgame[40] = 52;
nextgame[41] = nextgame[42] = 53;
nextgame[43] = nextgame[44] = 54;
nextgame[45] = nextgame[46] = 55;
nextgame[47] = nextgame[48] = 56;
nextgame[49] = nextgame[50] = 57;
nextgame[51] = nextgame[52] = 58;
nextgame[53] = nextgame[54] = 59;
nextgame[55] = nextgame[56] = 60;
nextgame[57] = nextgame[58] = 61;
nextgame[59] = nextgame[60] = 62;
nextgame[61] = nextgame[62] = 63;
function PlayerIDCheck()
{ var form = self.document.forms["PickEntry"];
if(form.PLAYERID.value=="")
{ oldAlert(" You must enter: Name Last,First.");
form.PLAYERID.focus();
return false;}
else { return true;}}
function PlayerInfo3Check()
{ var form = self.document.forms["PickEntry"];
if(form.PLAYERINFO3.value=="")
{ oldAlert(" You must enter: E-Mail Address.");
form.PLAYERINFO3.focus();
return false;}
else { return true;}}
function PlayerInfo3MailCheck()
{ var form = self.document.forms["PickEntry"];
if ((form.PLAYERINFO3.value == " ") ||(form.PLAYERINFO3.value.indexOf ('@',
0) == -1) ||(form.PLAYERINFO3.value.indexOf ('.', 0) == -1))
{ oldAlert(" You must enter a valid e-mail address for the E-Mail
Address.");
form.PLAYERINFO3.focus();
return false;}
else { return true;}
}
function TieBreakerPointsCheck()
{ var form = self.document.forms["PickEntry"];
if(form.TIEBREAKER.value=="")
{ oldAlert(" You must enter: Tie Breaker Points.");
form.TIEBREAKER.focus();
return false;}
else { return true;}}
function VerifyPick()
{var form = self.document.forms["PickEntry"];
var NoPickMade = 0;
for(counter=1; counter <= 63; counter++)
{ var GamePick = document.PickEntry.elements["PICK"+counter].value;
if (GamePick == 64) {NoPickMade++;}}
if(NoPickMade > 0){ oldAlert(" You must enter a selection for every game.");
return false;}
else { return true;}}
function VerifyPage() {
if (! PlayerIDCheck()) { return false;}
if (! PlayerInfo3Check()) { return false;}
if (! PlayerInfo3MailCheck()) { return false;}
if (! VerifyPick()) { return false;}
if (! TieBreakerPointsCheck()) { return false;}
return true;}
// -->
</script>
<script language=VBScript>
<!--
Function makeMsgBox(title, mess, icon, buts, defbut, mods)
butVal = buts + (icon * 16) + (defbut * 256) + (mods * 4096)
makeMsgBox = MsgBox(mess, butVal, title)
End Function
// -->
</script>
Thanks for reading