Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-11-2009, 06:06 AM   PM User | #31
mbrewer
New Coder

 
Join Date: Mar 2009
Location: Bakersfield, CA
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
mbrewer is an unknown quantity at this point
Thanks so much to Old Pedant for getting me started on this and for pointing me in the right direction for posting the values. You are the man/woman! (don't want to be sexist)

You can see this all in action for this year's tournament at http://www.myterrio.com/tournament.php, but not until the seeds are announced on Sunday and the brackets are activated.

Here is an image of a sample bracket - http://www.myterrio.com/images/sample_bracket.jpg
mbrewer is offline   Reply With Quote
Old 03-11-2009, 06:12 AM   PM User | #32
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,187
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
It's great to see this actually in use!

It's enough to make me think maybe I'll produce an ASP version, even if I don't use it. Share it with others.


Thanks!
Old Pedant is offline   Reply With Quote
Old 03-11-2009, 06:13 AM   PM User | #33
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,187
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Oh, man, with logo images no less! LOL! Way too much work for me!
Old Pedant is offline   Reply With Quote
Old 03-14-2009, 05:22 AM   PM User | #34
ajhp3
New Coder

 
Join Date: Mar 2009
Posts: 21
Thanks: 1
Thanked 2 Times in 2 Posts
ajhp3 is an unknown quantity at this point
No Such Luck

i gave up..i thought i had it and i didnt. but great to see that you got it working mbrewer. congrads and i hope that it works well for ya.
Unfortunately, im new at all of this stuff and it just doesnt make sense to me yet with where and how i place things in the code.
Im sure one day ill know what the hell im doing.

thanks though guys for all the effort, and glad to see that at least someone benefited outta this thread.

Last edited by ajhp3; 03-14-2009 at 05:35 AM..
ajhp3 is offline   Reply With Quote
Old 03-14-2009, 07:50 AM   PM User | #35
mbrewer
New Coder

 
Join Date: Mar 2009
Location: Bakersfield, CA
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
mbrewer is an unknown quantity at this point
ajhp3... yo, it's all here for you. I was extremely new to all of this before figuring it out on my own - obviously with the help of others. If I can do it u can too... All the code is here for you and if you can't figure it out I would be more than happy to help u out (as I am sure Old Pedant would too). I have this in production right now, and really if you are even attempting this code you would be able to ask the right questions, if any, instead of just giving up. I am here to help you if you really want it!!!
mbrewer is offline   Reply With Quote
Old 03-14-2009, 07:58 AM   PM User | #36
mbrewer
New Coder

 
Join Date: Mar 2009
Location: Bakersfield, CA
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
mbrewer is an unknown quantity at this point
Seriously let us know where u are at and where u are stuck and we would be more than happy to help u out!!!
mbrewer is offline   Reply With Quote
Old 03-15-2009, 04:51 AM   PM User | #37
ajhp3
New Coder

 
Join Date: Mar 2009
Posts: 21
Thanks: 1
Thanked 2 Times in 2 Posts
ajhp3 is an unknown quantity at this point
ok ill get this together and post it
ajhp3 is offline   Reply With Quote
Old 03-15-2009, 04:32 PM   PM User | #38
ajhp3
New Coder

 
Join Date: Mar 2009
Posts: 21
Thanks: 1
Thanked 2 Times in 2 Posts
ajhp3 is an unknown quantity at this point
ok here is where i am at so far. Im not sure where to insert the submit button, nor where the submit button is going to take my information.
Also, in the final 4 part at the bottom of the page, the box for the region 1 winner doesnt work, as you have to click the winner in the bracket in order to advance them, so that is really weird. I would also like to set this up for each of the regions, as well as the final 4, and a full page view as well of their entire bracket. take a look at the code and let me know where im messing up and how i can improve this. thanks!
Code:
<html>
<head>
<style>
*     { font-family: arial; font-size: 12px; }
th    { border: solid black 3px; background-color: white; font-size: 16px; }
.team { border: solid black 2px; background-color: white; width: 120px; height: 24px; }
.team2 { border: solid black 2px; background-color: white; width: 120px; height: 24px; }
.team3 { border: solid red 2px; background-color: yellow; width: 120px; height: 24px; }
</style>
<script>
function win(winner)
{
var team = winner.value;
var levels = winner.name.substring(3).split("_");
var curlevel = parseInt(levels[0]);
var curgame = parseInt(levels[1]);

var nextlevel = curlevel + 1;
var nextgame = Math.floor( (curgame+1) / 2 );

var curteam = winner.form.elements["WIN"+nextlevel+"_"+nextgame].value;
var winnerButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
if ( winnerButton == null ) return;

++nextlevel;
nextgame = Math.floor( (nextgame+1) / 2 );
var nextButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
var forward = ( nextButton != null && nextButton.value == winnerButton.value );

winnerButton.value = team;
while ( forward ) {
nextButton.value = " ";
++nextlevel;
nextgame = Math.floor( (nextgame+1) / 2 );
nextButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
forward = ( nextButton != null && nextButton.value == curteam );
}
} 

function getvalues(winner) 
{
    var frm = winner.form;
    for ( var e = 0; e < frm.elements.length; ++e )
    {
        var fld = frm.elements[e];
        if ( fld.name.substring(0,3) == "WIN" && fld.name.substring(0,4) != "WIN0" )
        {
             frm.elements["pick" + fld.name.substring(4)].value = fld.value;
        }
   }
}
</script>

</head>
<body>
<form>
<table border=0 cellpadding=0>
<tr>
	<th colspan=4 style="font-size: x-large;">West Region</th>
	<th colspan=3 style="font-size: x-large;">2009 Men's NCAA Basketball Tournament</th>
</tr>
<tr>
	<th colspan=1>1st Round</th>
	<th colspan=1>2nd Round</th>
	<th colspan=1>Sweet 16</th>
	<th colspan=1>Elight 8</th>
	<th colspan=1>Final 4</th>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_1" onclick="win(this)" value="#1 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type="button" class="team" name="WIN1_1" id="WIN1_1" onclick="win(this)" value="<?php echo $pick1_1; ?>"<input type="hidden" name="pick1_1" id="pick1_1">
></td>
    
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_2" onclick="win(this)" value="#16 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_1" id="WIN2_1" onclick="win(this)" value="?php echo $pick2_1; ?>"><input type="hidden" name="pick2_1" id="pick2_1">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_3" onclick="win(this)" value="#8 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_2" id="WIN1_2" onclick="win(this)" value="<?php echo $pick1_2; ?>"><input type="hidden" name="pick1_2" id="pick1_2">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_4" onclick="win(this)" value="#9 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN3_1" id="WIN3_1" onclick="win(this)" value="<?php echo $pick3_1; ?>"><input type="hidden" name="pick3_1" id="pick3_1">
</td>
</tr>
<tr>
	
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_5" onclick="win(this)" value="#4 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_3" id="WIN1_3" onclick="win(this)" value="<?php echo $pick1_3; ?>"><input type="hidden" name="pick1_3" id="pick1_3">
</td>

</tr>
<tr>
    <td><input type=button class="team" name="WIN0_6" onclick="win(this)" value="#13 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_2" id="WIN2_2" onclick="win(this)" value="<?php echo $pick2_2; ?>"><input type="hidden" name="pick2_2" id="pick2_2">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_7" onclick="win(this)" value="#5 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_4" id="WIN1_4" onclick="win(this)" value="<?php echo $pick1_4; ?>"><input type="hidden" name="pick1_4" id="pick1_4">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_8" onclick="win(this)" value="#12 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_1" id="WIN4_1" onclick="win(this)" value="<?php echo $pick4_1; ?>"><input type="hidden" name="pick4_1" id="pick4_1">
</td>
</tr>
<tr>
	
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_9" onclick="win(this)" value="#3 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_5" id="WIN1_5" onclick="win(this)" value="<?php echo $pick1_5; ?>"><input type="hidden" name="pick1_5" id="pick1_5">
</td>

</tr>
<tr>
    <td><input type=button class="team" name="WIN0_10" onclick="win(this)" value="#14 Seed" ></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_3" id="WIN2_3" onclick="win(this)" value="<?php echo $pick2_3; ?>"><input type="hidden" name="pick2_3" id="pick2_3">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_11" onclick="win(this)" value="#6 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_6" id="WIN1_6" onclick="win(this)" value="<?php echo $pick1_6; ?>"><input type="hidden" name="pick1_6" id="pick1_6">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_12" onclick="win(this)" value="#11 Seed" ></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN3_2" id="WIN3_2" onclick="win(this)" value="<?php echo $pick3_2; ?>"><input type="hidden" name="pick3_2" id="pick3_2">
</td>
</tr>
<tr>
	
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_13" onclick="win(this)" value="#2 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_7" id="WIN1_7" onclick="win(this)" value="<?php echo $pick1_7; ?>"><input type="hidden" name="pick1_7" id="pick1_7">
</td>

</tr>
<tr>
    <td><input type=button class="team" name="WIN0_14" onclick="win(this)" value="#15 Seed" ></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_4" id="WIN2_4" onclick="win(this)" value="<?php echo $pick2_4; ?>"><input type="hidden" name="pick2_4" id="pick2_4">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_15" onclick="win(this)" value="#7 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_8" id="WIN1_8" onclick="win(this)" value="<?php echo $pick1_8; ?>"><input type="hidden" name="pick1_8" id="pick1_8">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_16" onclick="win(this)" value="#10 Seed" ></td>
</tr>
<tr>
	
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_5" onclick="win(this)" value="region #1 winner"></td>
</tr>
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><input type=button class="team3" name="WIN5_1" onclick="win(this)" value=""></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_2" onclick="win(this)" value="region #2 winner"></td>
</tr>
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td colspan=2 style="font-size: 20px; text-align: right;">CHAMPION:&nbsp;&nbsp;</td>
    <td><input type=button class="team" 
               style="width: 160px; font-size: 20px; background-color: red; height: 32px;"
               name="WIN6_1" onclick="win(this)" value=""></td>
</tr>

<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_3" onclick="win(this)" value="region #3 winner"></td>
</tr>
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><input type=button class="team3" name="WIN5_2" onclick="win(this)" value=""></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_4" onclick="win(this)" value="region #4 winner"></td>
</tr>

</table>
</form>
</body> 
</html>
ajhp3 is offline   Reply With Quote
Old 03-15-2009, 08:03 PM   PM User | #39
mbrewer
New Coder

 
Join Date: Mar 2009
Location: Bakersfield, CA
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
mbrewer is an unknown quantity at this point
1. In your WIN1_1 button you have a syntax error - you need an '>' before the hidden field input and remove the '>' after.

2. In your WIN2_1 button you have a syntax error - you need an '<' before the ?php echo $pick2_1; ?>".

3. Everything else seems to work. You just need a traditional submit button to submit the values to the next page and to finish up your <form> statement.

<form action="somepage.php" method="post">
<input name="Submit" type="submit" value="Submit" onClick="getvalues(this)">

4. Then on somepage.php use php to get the values and store in a database.

$pick1_1 = $_POST["pick1_1"];
$pick1_2 = $_POST["pick1_2"];
...
$pick4_1 = $_POST["pick4_1"];

Let me know if you have any more questions.
mbrewer is offline   Reply With Quote
Old 03-15-2009, 09:13 PM   PM User | #40
unrelenting
Regular Coder

 
Join Date: Jan 2007
Posts: 142
Thanks: 9
Thanked 1 Time in 1 Post
unrelenting is an unknown quantity at this point
Quote:
Originally Posted by mbrewer View Post
1. In your WIN1_1 button you have a syntax error - you need an '>' before the hidden field input and remove the '>' after.

2. In your WIN2_1 button you have a syntax error - you need an '<' before the ?php echo $pick2_1; ?>".

3. Everything else seems to work. You just need a traditional submit button to submit the values to the next page and to finish up your <form> statement.

<form action="somepage.php" method="post">
<input name="Submit" type="submit" value="Submit" onClick="getvalues(this)">

4. Then on somepage.php use php to get the values and store in a database.

$pick1_1 = $_POST["pick1_1"];
$pick1_2 = $_POST["pick1_2"];
...
$pick4_1 = $_POST["pick4_1"];

Let me know if you have any more questions.
mbrewer, what code did you use for checking that all fields were complete before database insertion?

ajhp3, you need to change name="WIN4_5" to name="WIN4_1" to fix the region 1 winner problem.

After further testing, the code ajhp3 posted doesn't send any data at all to the insertion page I created. I just simply echoed the values out on the insertion page and each variable hold no data. I took out the method and the url looks like this...

Code:
http://mywebsite.com/tourney.php?pick1_1=&pick2_1=&pick1_2=&pick3_1=&pick1_3=&pick2_2=&pick1_4=&pick4_1=&pick1_5=&pick2_3=&pick1_6=&pick3_2=&pick1_7=&pick2_4=&pick1_8=&Submit=Submit
Code:
<html>
<head>
<style>
*     { font-family: arial; font-size: 12px; }
th    { border: solid black 3px; background-color: white; font-size: 16px; }
.team { border: solid black 2px; background-color: white; width: 120px; height: 24px; }
.team2 { border: solid black 2px; background-color: white; width: 120px; height: 24px; }
.team3 { border: solid red 2px; background-color: yellow; width: 120px; height: 24px; }
</style>
<script>
function win(winner)
{
var team = winner.value;
var levels = winner.name.substring(3).split("_");
var curlevel = parseInt(levels[0]);
var curgame = parseInt(levels[1]);

var nextlevel = curlevel + 1;
var nextgame = Math.floor( (curgame+1) / 2 );

var curteam = winner.form.elements["WIN"+nextlevel+"_"+nextgame].value;
var winnerButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
if ( winnerButton == null ) return;

++nextlevel;
nextgame = Math.floor( (nextgame+1) / 2 );
var nextButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
var forward = ( nextButton != null && nextButton.value == winnerButton.value );

winnerButton.value = team;
while ( forward ) {
nextButton.value = " ";
++nextlevel;
nextgame = Math.floor( (nextgame+1) / 2 );
nextButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
forward = ( nextButton != null && nextButton.value == curteam );
}
} 

function getvalues(winner) 
{
    var frm = winner.form;
    for ( var e = 0; e < frm.elements.length; ++e )
    {
        var fld = frm.elements[e];
        if ( fld.name.substring(0,3) == "WIN" && fld.name.substring(0,4) != "WIN0" )
        {
             frm.elements["pick" + fld.name.substring(4)].value = fld.value;
        }
   }
}
</script>

</head>
<body>
<form action="insert_picks.php" method="post">
<table border=0 cellpadding=0>
<tr>
	<th colspan=4 style="font-size: x-large;">West Region</th>
	<th colspan=3 style="font-size: x-large;">2009 NCAA Basketball Tournament</th>
</tr>
<tr>
	<th colspan=1>1st Round</th>
	<th colspan=1>2nd Round</th>
	<th colspan=1>Sweet 16</th>
	<th colspan=1>Elite 8</th>
	<th colspan=1>Final 4</th>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_1" onclick="win(this)" value="#1 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_1" id="WIN1_1" onclick="win(this)" value="<?php echo $pick1_1; ?>"><input type="hidden" name="pick1_1" id="pick1_1">
</td>
    
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_2" onclick="win(this)" value="#16 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_1" id="WIN2_1" onclick="win(this)" value="<?php echo $pick2_1; ?>"><input type="hidden" name="pick2_1" id="pick2_1">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_3" onclick="win(this)" value="#8 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_2" id="WIN1_2" onclick="win(this)" value="<?php echo $pick1_2; ?>"><input type="hidden" name="pick1_2" id="pick1_2">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_4" onclick="win(this)" value="#9 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN3_1" id="WIN3_1" onclick="win(this)" value="<?php echo $pick3_1; ?>"><input type="hidden" name="pick3_1" id="pick3_1">
</td>
</tr>
<tr>
	
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_5" onclick="win(this)" value="#4 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_3" id="WIN1_3" onclick="win(this)" value="<?php echo $pick1_3; ?>"><input type="hidden" name="pick1_3" id="pick1_3">
</td>

</tr>
<tr>
    <td><input type=button class="team" name="WIN0_6" onclick="win(this)" value="#13 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_2" id="WIN2_2" onclick="win(this)" value="<?php echo $pick2_2; ?>"><input type="hidden" name="pick2_2" id="pick2_2">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_7" onclick="win(this)" value="#5 Seed"></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_4" id="WIN1_4" onclick="win(this)" value="<?php echo $pick1_4; ?>"><input type="hidden" name="pick1_4" id="pick1_4">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_8" onclick="win(this)" value="#12 Seed"></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_1" id="WIN4_1" onclick="win(this)" value="<?php echo $pick4_1; ?>"><input type="hidden" name="pick4_1" id="pick4_1">
</td>
</tr>
<tr>
	
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_9" onclick="win(this)" value="#3 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_5" id="WIN1_5" onclick="win(this)" value="<?php echo $pick1_5; ?>"><input type="hidden" name="pick1_5" id="pick1_5">
</td>

</tr>
<tr>
    <td><input type=button class="team" name="WIN0_10" onclick="win(this)" value="#14 Seed" ></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_3" id="WIN2_3" onclick="win(this)" value="<?php echo $pick2_3; ?>"><input type="hidden" name="pick2_3" id="pick2_3">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_11" onclick="win(this)" value="#6 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_6" id="WIN1_6" onclick="win(this)" value="<?php echo $pick1_6; ?>"><input type="hidden" name="pick1_6" id="pick1_6">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_12" onclick="win(this)" value="#11 Seed" ></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN3_2" id="WIN3_2" onclick="win(this)" value="<?php echo $pick3_2; ?>"><input type="hidden" name="pick3_2" id="pick3_2">
</td>
</tr>
<tr>
	
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_13" onclick="win(this)" value="#2 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_7" id="WIN1_7" onclick="win(this)" value="<?php echo $pick1_7; ?>"><input type="hidden" name="pick1_7" id="pick1_7">
</td>

</tr>
<tr>
    <td><input type=button class="team" name="WIN0_14" onclick="win(this)" value="#15 Seed" ></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team2" name="WIN2_4" id="WIN2_4" onclick="win(this)" value="<?php echo $pick2_4; ?>"><input type="hidden" name="pick2_4" id="pick2_4">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_15" onclick="win(this)" value="#7 Seed" ></td>
</tr>
<tr>
    <td></td>
    <td><input type=button class="team" name="WIN1_8" id="WIN1_8" onclick="win(this)" value="<?php echo $pick1_8; ?>"><input type="hidden" name="pick1_8" id="pick1_8">
</td>
</tr>
<tr>
    <td><input type=button class="team" name="WIN0_16" onclick="win(this)" value="#10 Seed" ></td>
</tr>
<tr>
	
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><input type=button class="team3" name="WIN5_1" onclick="win(this)" value=""></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_2" onclick="win(this)" value="region #2 winner"></td>
</tr>
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td colspan=2 style="font-size: 20px; text-align: right;">CHAMPION:&nbsp;&nbsp;</td>
    <td><input type=button class="team" 
               style="width: 160px; font-size: 20px; background-color: red; height: 32px;"
               name="WIN6_1" onclick="win(this)" value=""></td>
</tr>

<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_3" onclick="win(this)" value="region #3 winner"></td>
</tr>
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><input type=button class="team3" name="WIN5_2" onclick="win(this)" value=""></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=button class="team3" name="WIN4_4" onclick="win(this)" value="region #4 winner"></td>
</tr>

</table>
<input name="Submit" type="submit" value="Submit" onClick="getvalues(this)">
</form>
</body> 
</html>

Last edited by unrelenting; 03-15-2009 at 10:54 PM..
unrelenting is offline   Reply With Quote
Old 03-16-2009, 09:06 AM   PM User | #41
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,187
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
What's the point of the
value="?php echo $pick2_1; ?>"
in all the non-level-zero buttons???

Are you wanting to submit this to a PHP page and then come back and have the same values re-displayed?? If so, then I can see the point.

And this is just a curiosity question:

Why code
value="<?php echo $pick1_3; ?>">
instead of the shorter--and as I understand it as a non PHP person--and equivalent
value="<?= $pick1_3 ?>"
???
Old Pedant is offline   Reply With Quote
Old 03-16-2009, 09:29 AM   PM User | #42
mbrewer
New Coder

 
Join Date: Mar 2009
Location: Bakersfield, CA
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
mbrewer is an unknown quantity at this point
Exactly - up until the first game on Thursday people can come back and change their picks so we want to grab their selections from the database and display them upon return to the page.

I am not familiar with your shorthand for outputting values in PHP. I checked the PHP manual and couldn't find anything about it, but tried it out and it worked.

Last edited by mbrewer; 03-16-2009 at 10:02 AM..
mbrewer is offline   Reply With Quote
Old 03-16-2009, 09:40 AM   PM User | #43
mbrewer
New Coder

 
Join Date: Mar 2009
Location: Bakersfield, CA
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
mbrewer is an unknown quantity at this point
unrelenting - I don't check that all fields are complete before submitting because I allow for people to submit picks without filling out all fields and then they can come back later and finish or change their picks up until the first game on Thursday. The getvalues() function onsubmit gets all of the values and puts them in to the hidden fields whether they are empty or not.

There is something wrong with the getvalues() function that you are using and that is why you aren't getting the data on the next page. Start with the following and shorten it using for loops if you like.

function getvalues(winner) {
winner.form.pick1_1.value = winner.form.elements["WIN1_1"].value;
winner.form.pick1_2.value = winner.form.elements["WIN1_2"].value;
winner.form.pick1_3.value = winner.form.elements["WIN1_3"].value;
winner.form.pick1_4.value = winner.form.elements["WIN1_4"].value;
winner.form.pick1_5.value = winner.form.elements["WIN1_5"].value;
winner.form.pick1_6.value = winner.form.elements["WIN1_6"].value;
winner.form.pick1_7.value = winner.form.elements["WIN1_7"].value;
winner.form.pick1_8.value = winner.form.elements["WIN1_8"].value;
winner.form.pick2_1.value = winner.form.elements["WIN2_1"].value;
winner.form.pick2_2.value = winner.form.elements["WIN2_2"].value;
winner.form.pick2_3.value = winner.form.elements["WIN2_3"].value;
winner.form.pick2_4.value = winner.form.elements["WIN2_4"].value;
winner.form.pick3_1.value = winner.form.elements["WIN3_1"].value;
winner.form.pick3_2.value = winner.form.elements["WIN3_2"].value;
winner.form.pick4_1.value = winner.form.elements["WIN4_1"].value;
}

I tested it and it outputted all the correct values - http://www.myterrio.com/test.php

Last edited by mbrewer; 03-16-2009 at 09:48 AM..
mbrewer is offline   Reply With Quote
Users who have thanked mbrewer for this post:
unrelenting (03-17-2009)
Old 03-16-2009, 12:13 PM   PM User | #44
unrelenting
Regular Coder

 
Join Date: Jan 2007
Posts: 142
Thanks: 9
Thanked 1 Time in 1 Post
unrelenting is an unknown quantity at this point
Thanks, mbrewer. I'll give it a whirl again this evening.
unrelenting is offline   Reply With Quote
Old 03-17-2009, 12:07 AM   PM User | #45
unrelenting
Regular Coder

 
Join Date: Jan 2007
Posts: 142
Thanks: 9
Thanked 1 Time in 1 Post
unrelenting is an unknown quantity at this point
Works great, mbrewer. Thanks.

Now I'm wondering what apporach to take on the other 3 brackets as far as numbering the games. How did you do that?

Such as $pick1_1 and WIN1_1works in the first regional but in the next regional it would need a new number that would work with the java code I'm assuming.
unrelenting is offline   Reply With Quote
Reply

Bookmarks

Tags
codes, javascript, ncaa tournament, onclick

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:47 PM.


Advertisement
Log in to turn off these ads.