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=JavaSc ript>
<!--
function InitWindow()
{document.PickE ntry.reset();}
IE4 = document.all;
function oldAlert(mess) {
newAlert(" Entry Error",mess,3,0 );
}
function newAlert(title, mess,icon,mods) {
(IE4) ? makeMsgBox(titl e,mess,icon,0,0 ,mods) : alert(mess);
}
function newConfirm(titl e,mess,icon,def but,mods) {
if (IE4) {
icon = (icon==0) ? 0 : 2;
defbut = (defbut==0) ? 0 : 1;
retVal = makeMsgBox(titl e,mess,icon,4,d efbut,mods);
retVal = (retVal==6);
}
else {
retVal = confirm(mess);
}
return retVal;
}
function newPrompt(title ,mess,def) {
retVal = (IE4) ? makeInputBox(ti tle,mess,def) : prompt(mess,def );
if (retVal) {}
else {retVal = '';}
return retVal;
}
function WriteIt(id, text)
{if (document.layer s){
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.index Of(out)>-1){
pos= teamtext.indexO f(out);
teamtext = "" + (teamtext.subst ring(0, pos) + add +
teamtext.substr ing((pos + out.length), teamtext.length ));}
ol.document.ope n();
ol.document.wri te('<span class="oddrow"> '+teamtext+'</span>');
ol.document.clo se();
ol.clip.width=l .clip.width=ol. document.width;
ol.clip.height= l.clip.height=o l.document.heig ht;}
else if (document.all || document.getEle mentById) {
if (document.all)
document.all[id].innerText = text;
else {
var l = document.getEle mentById(id);
var r = document.create Range();
r.setStartAfter (l);
var docFrag = r.createContext ualFragment(tex t);
while (l.hasChildNode s())
l.removeChild(l .firstChild);
l.appendChild(d ocFrag);}
}
}
function PickIt(pickid, teamid)
{var id="entry"+pick id;
var currpick = document.PickEn try.elements["PICK"+pick id].value;
if (pickid > 32){
teamid = document.PickEn try.elements["PICK"+team id].value;
if (teamid == 64) {return;}
teamid++;}
if (currpick == teamid-1){return;};
var text=document.P ickEntry.elemen ts["TEAM"+team id].value;
document.PickEn try.elements["PICK"+pick id].value = teamid-1;
WriteIt(id, text);
var nextround = pickid;
while (nextround != 63){
var nextroundpick =
document.PickEn try.elements["PICK"+next game[nextround]].value;
if (nextroundpick != 64){
if (nextroundpick == currpick){
if (nextroundpick != teamid-1){
document.PickEn try.elements["PICK"+next game[nextround]].value = teamid-1;
WriteIt("entry" +nextgame[nextround],text);
}
}
}
nextround = nextgame[nextround];}
}
var spacer=' ';
if(document.lay ers){
for(counter=2; counter <= 15; counter++)
{spacer=spacer+ ' '}
origWidth=inner Width;
origHeight=inne rHeight;
onresize=functi on(){
if(innerWidth!= origWidth||inne rHeight!=origHe ight)
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.f orms["PickEntry"];
if(form.PLAYERI D.value=="")
{ oldAlert(" You must enter: Name Last,First.");
form.PLAYERID.f ocus();
return false;}
else { return true;}}
function PlayerInfo3Chec k()
{ var form = self.document.f orms["PickEntry"];
if(form.PLAYERI NFO3.value=="")
{ oldAlert(" You must enter: E-Mail Address.");
form.PLAYERINFO 3.focus();
return false;}
else { return true;}}
function PlayerInfo3Mail Check()
{ var form = self.document.f orms["PickEntry"];
if ((form.PLAYERIN FO3.value == " ") ||(form.PLAYERI NFO3.value.inde xOf ('@',
0) == -1) ||(form.PLAYERI NFO3.value.inde xOf ('.', 0) == -1))
{ oldAlert(" You must enter a valid e-mail address for the E-Mail
Address.");
form.PLAYERINFO 3.focus();
return false;}
else { return true;}
}
function TieBreakerPoint sCheck()
{ var form = self.document.f orms["PickEntry"];
if(form.TIEBREA KER.value=="")
{ oldAlert(" You must enter: Tie Breaker Points.");
form.TIEBREAKER .focus();
return false;}
else { return true;}}
function VerifyPick()
{var form = self.document.f orms["PickEntry"];
var NoPickMade = 0;
for(counter=1; counter <= 63; counter++)
{ var GamePick = document.PickEn try.elements["PICK"+coun ter].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 (! PlayerInfo3Chec k()) { return false;}
if (! PlayerInfo3Mail Check()) { return false;}
if (! VerifyPick()) { return false;}
if (! TieBreakerPoint sCheck()) { return false;}
return true;}
// -->
</script>
<script language=VBScri pt>
<!--
Function makeMsgBox(titl e, 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=JavaSc ript>
<!--
function InitWindow()
{document.PickE ntry.reset();}
IE4 = document.all;
function oldAlert(mess) {
newAlert(" Entry Error",mess,3,0 );
}
function newAlert(title, mess,icon,mods) {
(IE4) ? makeMsgBox(titl e,mess,icon,0,0 ,mods) : alert(mess);
}
function newConfirm(titl e,mess,icon,def but,mods) {
if (IE4) {
icon = (icon==0) ? 0 : 2;
defbut = (defbut==0) ? 0 : 1;
retVal = makeMsgBox(titl e,mess,icon,4,d efbut,mods);
retVal = (retVal==6);
}
else {
retVal = confirm(mess);
}
return retVal;
}
function newPrompt(title ,mess,def) {
retVal = (IE4) ? makeInputBox(ti tle,mess,def) : prompt(mess,def );
if (retVal) {}
else {retVal = '';}
return retVal;
}
function WriteIt(id, text)
{if (document.layer s){
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.index Of(out)>-1){
pos= teamtext.indexO f(out);
teamtext = "" + (teamtext.subst ring(0, pos) + add +
teamtext.substr ing((pos + out.length), teamtext.length ));}
ol.document.ope n();
ol.document.wri te('<span class="oddrow"> '+teamtext+'</span>');
ol.document.clo se();
ol.clip.width=l .clip.width=ol. document.width;
ol.clip.height= l.clip.height=o l.document.heig ht;}
else if (document.all || document.getEle mentById) {
if (document.all)
document.all[id].innerText = text;
else {
var l = document.getEle mentById(id);
var r = document.create Range();
r.setStartAfter (l);
var docFrag = r.createContext ualFragment(tex t);
while (l.hasChildNode s())
l.removeChild(l .firstChild);
l.appendChild(d ocFrag);}
}
}
function PickIt(pickid, teamid)
{var id="entry"+pick id;
var currpick = document.PickEn try.elements["PICK"+pick id].value;
if (pickid > 32){
teamid = document.PickEn try.elements["PICK"+team id].value;
if (teamid == 64) {return;}
teamid++;}
if (currpick == teamid-1){return;};
var text=document.P ickEntry.elemen ts["TEAM"+team id].value;
document.PickEn try.elements["PICK"+pick id].value = teamid-1;
WriteIt(id, text);
var nextround = pickid;
while (nextround != 63){
var nextroundpick =
document.PickEn try.elements["PICK"+next game[nextround]].value;
if (nextroundpick != 64){
if (nextroundpick == currpick){
if (nextroundpick != teamid-1){
document.PickEn try.elements["PICK"+next game[nextround]].value = teamid-1;
WriteIt("entry" +nextgame[nextround],text);
}
}
}
nextround = nextgame[nextround];}
}
var spacer=' ';
if(document.lay ers){
for(counter=2; counter <= 15; counter++)
{spacer=spacer+ ' '}
origWidth=inner Width;
origHeight=inne rHeight;
onresize=functi on(){
if(innerWidth!= origWidth||inne rHeight!=origHe ight)
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.f orms["PickEntry"];
if(form.PLAYERI D.value=="")
{ oldAlert(" You must enter: Name Last,First.");
form.PLAYERID.f ocus();
return false;}
else { return true;}}
function PlayerInfo3Chec k()
{ var form = self.document.f orms["PickEntry"];
if(form.PLAYERI NFO3.value=="")
{ oldAlert(" You must enter: E-Mail Address.");
form.PLAYERINFO 3.focus();
return false;}
else { return true;}}
function PlayerInfo3Mail Check()
{ var form = self.document.f orms["PickEntry"];
if ((form.PLAYERIN FO3.value == " ") ||(form.PLAYERI NFO3.value.inde xOf ('@',
0) == -1) ||(form.PLAYERI NFO3.value.inde xOf ('.', 0) == -1))
{ oldAlert(" You must enter a valid e-mail address for the E-Mail
Address.");
form.PLAYERINFO 3.focus();
return false;}
else { return true;}
}
function TieBreakerPoint sCheck()
{ var form = self.document.f orms["PickEntry"];
if(form.TIEBREA KER.value=="")
{ oldAlert(" You must enter: Tie Breaker Points.");
form.TIEBREAKER .focus();
return false;}
else { return true;}}
function VerifyPick()
{var form = self.document.f orms["PickEntry"];
var NoPickMade = 0;
for(counter=1; counter <= 63; counter++)
{ var GamePick = document.PickEn try.elements["PICK"+coun ter].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 (! PlayerInfo3Chec k()) { return false;}
if (! PlayerInfo3Mail Check()) { return false;}
if (! VerifyPick()) { return false;}
if (! TieBreakerPoint sCheck()) { return false;}
return true;}
// -->
</script>
<script language=VBScri pt>
<!--
Function makeMsgBox(titl e, mess, icon, buts, defbut, mods)
butVal = buts + (icon * 16) + (defbut * 256) + (mods * 4096)
makeMsgBox = MsgBox(mess, butVal, title)
End Function
// -->
</script>
Thanks for reading
Comment