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 8 2567
This code doesn't tell us much, except that "Picks" are referred to as
numbers. I would assume that these numbers are passed from probably
HTML <select> menu drop downs. As such, you probably have attritubutes
that match something like <option value="0">Kentu cky</option>
In the end, it is whatever HTML form value that is posted to your form
handler that is inserted into the database, not what the javascript
does, (unless the JS changes the HTML form value.)
On your form handler, you might have to make a teamID mapping to make a
conversion before inserting into your database.
Jimmy Smits wrote: 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
I'm guessing that your script works only in IE and maybe older
Netscape. It needs some serious cleaning up.
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.
[...]
I'll presume that the selection is made by an option within a
select element. If so, look at this line:
var currpick = document.PickEn try.elements["PICK"+pick id].value;
The select (probably) has a name of PICK plus a number. It then
has a value and some text, the HTML probably looks something
like:
<option name="PICK0" value="0" ...>Kentucky</option>
The line above selects the value of the option "0". You want
the text "Kentucky". So change the line to:
var currpick = document.PickEn try.elements["PICK"+pick id].text;
In regard to cleaning up the script, consider the following:
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); }
Any browser that your script thinks supports "document.a ll" will
be classified as "IE4". Your script will then attempt to call
"makeMsgBox ()", which will not work on all browsers that support
document.all, nor will it work on any platform that does not
support VBscript (since makeMsgBox() is defined later as a
VBscript function).
There are likely numerous other examples in the script.
Essentially, only visitors running IE on Windows will be able
to use this script.
--
Rob
Spats30 wrote: This code doesn't tell us much, except that "Picks" are referred to as numbers. I would assume that these numbers are passed from probably HTML <select> menu drop downs. As such, you probably have attritubutes that match something like <option value="0">Kentu cky</option>
In the end, it is whatever HTML form value that is posted to your form handler that is inserted into the database, not what the javascript does, (unless the JS changes the HTML form value.)
On your form handler, you might have to make a teamID mapping to make a conversion before inserting into your database.
Alternatively, simply remove the value from the option. If no
value is given, the contents of the option are submitted.
Changing your line above to:
<option>Kentuck y</option>
means that "Kentucky" will be submitted.
From the HTML 4.01 spec:
OPTION Attribute definitions
...
value = cdata [CS]
This attribute specifies the initial value of the control. If
this attribute is not set, the initial value is set to the
contents of the OPTION element.
<URL:http://www.w3.org/TR/html4/interact/forms.html#h-17.6>
--
Rob
"RobG" <rg***@iinet.ne t.auau> wrote in message
news:l1******** *********@news. optus.net.au... Jimmy Smits wrote: 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
I'm guessing that your script works only in IE and maybe older Netscape. It needs some serious cleaning up.
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. [...]
I'll presume that the selection is made by an option within a select element. If so, look at this line:
var currpick = document.PickEn try.elements["PICK"+pick id].value;
The select (probably) has a name of PICK plus a number. It then has a value and some text, the HTML probably looks something like:
<option name="PICK0" value="0" ...>Kentucky</option>
The line above selects the value of the option "0". You want the text "Kentucky". So change the line to:
var currpick = document.PickEn try.elements["PICK"+pick id].text;
In regard to cleaning up the script, consider the following:
> 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); > }
Any browser that your script thinks supports "document.a ll" will be classified as "IE4". Your script will then attempt to call "makeMsgBox ()", which will not work on all browsers that support document.all, nor will it work on any platform that does not support VBscript (since makeMsgBox() is defined later as a VBscript function).
There are likely numerous other examples in the script.
Essentially, only visitors running IE on Windows will be able to use this script. -- Rob
Thanks so much for all your suggestions. I am going to poke around today and
see if I can make any of these ideas work. I will keep you posted!
Thanks Again!
"RobG" <rg***@iinet.ne t.auau> wrote in message
news:u9******** *********@news. optus.net.au... Spats30 wrote: This code doesn't tell us much, except that "Picks" are referred to as numbers. I would assume that these numbers are passed from probably HTML <select> menu drop downs. As such, you probably have attritubutes that match something like <option value="0">Kentu cky</option>
In the end, it is whatever HTML form value that is posted to your form handler that is inserted into the database, not what the javascript does, (unless the JS changes the HTML form value.)
On your form handler, you might have to make a teamID mapping to make a conversion before inserting into your database.
Alternatively, simply remove the value from the option. If no value is given, the contents of the option are submitted. Changing your line above to:
<option>Kentuck y</option>
means that "Kentucky" will be submitted.
From the HTML 4.01 spec:
OPTION Attribute definitions ... value = cdata [CS] This attribute specifies the initial value of the control. If this attribute is not set, the initial value is set to the contents of the OPTION element.
<URL:http://www.w3.org/TR/html4/interact/forms.html#h-17.6>
-- Rob
I am have sooo much to learn, I am understanding what you are saying. In
both of your posts. And there is alot of excess code in there that I am
trying to clean up because it doesnt apply to my site or to what I am doing.
In reference to your other post when I tried to change
var currpick = document.PickEn try.elements["PICK"+pick id].value;
to
var currpick = document.PickEn try.elements["PICK"+pick id].text;
It still gives me numbers in the DB. I am trying to follow the values of the
teams through the code but I get lost.
There are many Hidden inputs. The tournament has 64 winners. so there are 64
of these all with a value of 64.
<input type=hidden name=PICK1 value=64>
And this line is also in there along with others - one for each team of
course:
<input type=hidden name=TEAM1 value="Kentucky ">
Which before I ever posted here I thought would give me a value of 1 for
Kentucky - however Kentucky comes as "0"
Are these values not being submitted?
Thanks again for reading.
Anyone with any thoughts?
"Jimmy Smits" <ji****@hotmail .com> wrote in message
news:4u******** ************@re ad2.cgocable.ne t... "RobG" <rg***@iinet.ne t.auau> wrote in message news:u9******** *********@news. optus.net.au... Spats30 wrote: This code doesn't tell us much, except that "Picks" are referred to as numbers. I would assume that these numbers are passed from probably HTML <select> menu drop downs. As such, you probably have
attritubutes that match something like <option value="0">Kentu cky</option>
In the end, it is whatever HTML form value that is posted to your form handler that is inserted into the database, not what the javascript does, (unless the JS changes the HTML form value.)
On your form handler, you might have to make a teamID mapping to make
a conversion before inserting into your database. Alternatively, simply remove the value from the option. If no value is given, the contents of the option are submitted. Changing your line above to:
<option>Kentuck y</option>
means that "Kentucky" will be submitted.
From the HTML 4.01 spec:
OPTION Attribute definitions ... value = cdata [CS] This attribute specifies the initial value of the control. If this attribute is not set, the initial value is set to the contents of the OPTION element.
<URL:http://www.w3.org/TR/html4/interact/forms.html#h-17.6>
-- Rob
I am have sooo much to learn, I am understanding what you are saying. In both of your posts. And there is alot of excess code in there that I am trying to clean up because it doesnt apply to my site or to what I am
doing. In reference to your other post when I tried to change
var currpick = document.PickEn try.elements["PICK"+pick id].value;
to
var currpick = document.PickEn try.elements["PICK"+pick id].text;
It still gives me numbers in the DB. I am trying to follow the values of
the teams through the code but I get lost.
There are many Hidden inputs. The tournament has 64 winners. so there are
64 of these all with a value of 64. <input type=hidden name=PICK1 value=64>
And this line is also in there along with others - one for each team of course: <input type=hidden name=TEAM1 value="Kentucky "> Which before I ever posted here I thought would give me a value of 1 for Kentucky - however Kentucky comes as "0"
Are these values not being submitted?
Thanks again for reading.
Jimmy Smits wrote: Anyone with any thoughts?
[...]
Really need to see the entire page to work out what is
happening - I think that is beyond the scope of a news group.
If you want to post a URL, perhaps we can take it from there.
There are slabs of JS that very likely could be optimised, this
group can help with specific issues, but trying to fix 200 lines
of code without the HTML or any idea of what it is actually (or
supposed to be) doing is not very productive.
For example, the 30 lines that define the nextgame array could
be generated by:
var nextgame = [];
for (var i=1; i<63; i+=2){
nextgame[i] = nextgame[i+1] = Math.floor(i/2)+33;
}
If indeed an array is needed at all - it is quite possible that
the value of nextgame can be calculated when required, the
values in the array are not altered by the code you provided.
Similarly, all the IE specific stuff should be replaced with
simpler functions that are suitable for all browsers.
Reply via email if you wish (delete last "au").
--
Rob
JRS: In article <cU************ *****@news.optu s.net.au>, dated Tue, 15
Feb 2005 06:45:28, seen in news:comp.lang. javascript, RobG
<rg***@iinet.ne t.auau> posted : For example, the 30 lines that define the nextgame array could be generated by:
var nextgame = []; for (var i=1; i<63; i+=2){ nextgame[i] = nextgame[i+1] = Math.floor(i/2)+33; }
Or even by
var nextgame = []
for (var i=1, j=33; i<63; i+=2) nextgame[i] = nextgame[i+1] = j++
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ken in Melbourne Australia |
last post by:
If I use the curly bracket syntax (referred to as the
complex syntax) within a string, how do I get to call a
function within it?
The php manual says that the first (or previous)
character for the curly bracket has to be a dollar sign '$'.
This is fine for variables, arrays and some objects but
doesn't allow me to call a function such as addslashes() or
trim() before I return the string in the variable.
|
by: Steve |
last post by:
Hi,
I have a table which contains records of user access and searches made
within an application, this is a sample of the data:
response for 101 results from database in 28906 ms
I only want to keep the text contained in the brackets and nothing
else.
|
by: Daniel Billingsley |
last post by:
Speaking of trying to read deeply nested if-else blocks...
I often find it's not always easy to tell one indent level from another
(granted I keep my tab settings low so I'm not halfway across the page by
the 3rd level), and I find myself doing things like this to help me keep it
straight:
class MyClass
{
public void SomeMethod()
|
by: Peter Proost |
last post by:
Hi group,
I've got this bit of code (see below) which draws a basketball field in a
picturebox (width:198, height:368)
but now I was wondering what would be the easiest way to check inside the
picturebox mouseup event if I clicked inside or outside the 3point area,
because the 3point area isn't a real cirkle
Any hints or tips are welcome.
|
by: Diane |
last post by:
Could you please explain me how can I output nested strings?
Here is an example:
"adsd{rfkm}xcv"
The output should start from the inner parentheses, such as:
dfF
rfkm
| |
by: mutemode |
last post by:
I have this query
SELECT 'bracket' = CASE
WHEN income BETWEEN 0 AND 49 THEN '0-49'
WHEN income BETWEEN 50 AND 99 THEN '50-99'
WHEN income BETWEEN 100 AND 499 THEN '100-499'
WHEN income BETWEEN 500 AND 1000 THEN '500-1000'
ELSE 'Other' END, count(income) AS number
FROM #persons
GROUP BY CASE
|
by: Hazza |
last post by:
Hello,
I am teaching myself java and am completely stuck. I am using the java development kit and vista command prompt to compile and interpret programmes. I am getting error codes which don't make sense because they refer to a code that seems all right to me. Here is the code:
class calculator {
public static void main(String arguments) {
float numbera = 100;
float numberb = 200;
if (arguments.length > 0) {
...
|
by: Michelle Monty |
last post by:
Hello all, I'm trying to get a shot clock to work in my basketball game program. I've read a couple of tutorials but I'm still not getting it. I need it to start at 24 and go down to 0. As it is right now, it goes automatically to 0. Can anyone offer some advice? Thanks!
Timer1.Enabled = True
Label78.Text = 24
Do Until Label78.Text = 0
If Label78.Text = 0 Then Timer1.Enabled = False And...
|
by: Simon Woods |
last post by:
Hi
I'm new to Regular Expressions so ...
I trying to work out regular expressions to parse the following
(a + (b + c))
I really want to replace it with
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |