Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with NCAA march madness brackets

    With March madness right around the corner I am hoping to go paper less on my office pool. I have created a simple NFL pick sheet in html in the past but this is a bit out of my league as far as advancing teams as you pick them. I have found a thread here that has helped a me a bunch. I am not familer with java or how values work. My problem at this point is (having used a script from another thread here)
    http://www.codingforums.com/showthre...425#post895425
    What are the values I change when I move to a new region? as well as keep moving the selected team to the final four and so on.

    Here is what I have
    Code:
    <html>
    <head>
    <style>
    * { font-family: arial; font-size: 12px; }
    th { border: red 3px; background-color: red; color: black; font-size: 16px; }
    .team { border: red 2px; background-color: white; width: 120px; height: 24px; }
    .team2 { border: black 2px; background-color: wheat; width: 120px; height: 24px; }
    .team3 { border: black 2px; background-color: pink; width: 120px; height: 24px; }
    </style>
    Head I understand, the scripting I am thinking is what I need to change for each region YES/NO
    <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 );
    }
    }
    </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;">Final Four</th>
    </tr>
    <tr>
    <th colspan=2>Sub-Regional </th>
    <th colspan=2 style="background-color: wheat;">Regional Final</th>
    </tr>
    td = the tables or boxes through out the brackets, but what or how do you establish the name = "WIN0_1? these numbers change for each bracket and I am not sure how there figured?
    <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" onclick="win(this)" value=""></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" onclick="win(this)" value=""></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" onclick="win(this)" value=""></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" onclick="win(this)" value=""></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" onclick="win(this)" value=""></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" onclick="win(this)" value=""></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" onclick="win(this)" value=""></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" onclick="win(this)" value=""></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" onclick="win(this)" value="" ></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" onclick="win(this)" value="" ></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" onclick="win(this)" value="" ></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" onclick="win(this)" value="" ></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" onclick="win(this)" value="" ></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" onclick="win(this)" value="" ></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" onclick="win(this)" value="" ></td>
    </tr>
    <tr>
    <td><input type=button class="team" name="WIN0_16" onclick="win(this)" value="#10 Seed" ></td>
    </tr>
    <tr>
    <td colspan=8>and the other 3 regions...each with a regional 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: orange; 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>
    ...Help me Obi-Wan Kenobi your my only hope...
    Last edited by Kor; 12-07-2009 at 08:33 AM. Reason: wrap the code[code][/code]

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,333 Times in 4,299 Posts
    Well, I wrote the basic idea for that and then others took off and ran with it, so I'm not sure what "stage" of the script you are looking at.

    I created the HTML/JS for a 16-team division, and it just needed to be replicated 3 more times for the full 64.

    Now, this is completely overkill for the NFL playoffs, of course. Only 6 teams per conference, and 2 in each conference get byes the first week.

    So I wouldn't copy this slavishly for an NFL pool. I'd just use the concepts but otherwise pretty much start over.

    The names for the buttons are pretty simple: WINx_y means this is round x (round 0 means selection to the playoffs, round 1 means the team has won 1 game, etc.) and then y is just the team number IN THAT ROUND. In each round, teams always play in odd/even pairs: team 1 with team 2, team 15 with team 16. Then the winner is advanced to the next level with a team number that is half the higher number of the pair that played.

    So, in round 0, we have (example) teams WIN0_11 and WIN0_12 (seeds #6 and #11 as the values say). The winner moves to round 1 (WIN1_) and becomes the team numbered half of the even number (12) there, so it becomes WIN1_6.

    I probably could have been more consistent and either used 0 both for round and teams or not used zero at all. Don't ask me why I chose what I did. That's ancient history.

    ANYWAY...

    For the NFL playoffs you'd probably want something like:
    Code:
    ROUND1_1 ==>> ROUND2_1 (bye)
                         ==>> ROUND3_1
    ROUND1_4
             ==>> ROUND2_4
    ROUND1_5
                                      NFC CHAMP
    ROUND1_2 ==>> ROUND2_2 (bye)
                         ==>> ROUND3_2
    ROUND1_3
             ==>> ROUND2_3
    ROUND1_6
    and ditto for AFC.

    Here, the number after the underline means the seeding in that round. With so few teams, and with the byes, that's probably easier to keep track of.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Old Pedant I could not have done it without your help, I finally have it working. Sorry for the confussion I actually wanted a NCAA bracket not a NFL bracket, I was just mentioning that I have made an nfl one in the past that just picked a winner from the two games. Anyway, any ideas how to have the form submited to my via e-mail when a player fills it out?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,906
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by jedimaster_att View Post
    Anyway, any ideas how to have the form submited to my via e-mail when a player fills it out?
    The trouble with using this method (e-mail mailto) to send form results is its unpredictability. The method it is highly dependent on the browser in use and the email client in use (some people have only Yahoo or Hotmail). In particular, your visitor must have Internet Explorer as the browser and Outlook Express as the default client for this to work correctly. Even if your visitor is using Internet Explorer, but the default mail client is different (e.g Eudora) , your mailto form will not work. With all of the browser troubles, you're likely to lose about half of your users' messages. Most of the email clients that can successfully send a mail will prompt the user by a security dialog prior to sending - this can scare many users from continuing. Also, what about people with Javascript disabled?

    In fact few browsers these days accept mailto: as a form action. You need a really old browser for it to work as more modern browsers simply open the email program (if any) and ignore the form. If you are going to use a form then use a server-side formmail script as the action - there are several good free ones out there.

    For a simple PHP form feedback script see:- http://www.thesitewizard.com/archive/feedbackphp.shtml

  • #5
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok I have a free web hosting w/ php, but I cant figure out or get it to work! In the tutorial you sent me to in the above post, it says to put the feed back form it self in the body which I did. The problem I believe I am having is the part where I have to code "sendmail.php". It says to put
    <?php
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    mail( "yourname@example.com", "Feedback Form Results",
    $message, "From: $email" );
    header( "Location: http://www.example.com/thankyou.html" );
    ?>
    into its own file and not to put anything else in that file, and name the file sendmail.php.

    I am confussed here, where does this new file go? Is it writen into the html code? I get an 401 error when I press the submit button on my page.

    thanks, for any and all help.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,333 Times in 4,299 Posts
    I would make it a separate page.

    In the page with the brackets, you use something like
    Code:
    <form action="sendBracketMail.php" method="post">
    And then indeed create the PHP file with that name that does nothing but send the mail.

    Not a PHP person, but that's how I'd do it with either JSP or ASP.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am sorrry I am still not getting this PHP. I have a msqly host/database. Everything I have tried has given me an 404: page does not exsist. I have put a

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

    Brackets.php is a seperate page with my mysql info. Am I doing this right so far? I am not a program or computer wiz by any means. I feel like I am a fast learner though.
    If there is any PHP experts out there who know how I can simply create a NCAA March Madness bracket to post to my web site that my friends can fill out and email me there picks... then please help.

    As of right now I have a full 64 team, 4 region, with final four and championship game brackets in HTML with advancing buttons. It stops there.

    Thanks for any and all help...

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,333 Times in 4,299 Posts
    So show the important part: The PHP code. That is, the source for "brackets.php".

    Not sure why you have the onClick there for the submit button. What does that do??? That is, what does the getValues( ) function do??
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •