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.
Page 6 of 7 FirstFirst ... 4567 LastLast
Results 76 to 90 of 92
  1. #76
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the quick reply. I went back and copied your code exactly and made the adjustment but the images are not 'clickable' and are not passing on the value. Is there something I am missing?


    Using these two test images as an example:
    Code:
    <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 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;
        if ( forward ) winnerButton.click( );
    }
    </script>
    </head>
    <body>
    <form>
    <table border=0 cellpadding=3>
    <tr>
        <td class="team" onclick="win(this,1)"><img src="Duke.gif" alt="Duke"></td>
    </tr>
    <tr>
        <td></td>
        <td class="team" id="WIN1" onclick="win(this,33)">&nbsp;</td>
    </tr>
    <tr>
        <td class="team" onclick="win(this,1)"><img src="Virginia.gif" alt="Virginia"></td>
    </tr>
    </table>
    </form>

  2. #77
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    March Madness with a twist

    Finally found this topic!

    I'm a veteran database developer who has dabbled in webstuff, with some limited JavaScripting.

    I was asked by a small association here at home to see if I could throw up a bracket for them for the local March/April madness which is the top 8 basketball teams competing for the title.

    The format consists of 3 rounds, in the first round a team has to win 2 matches against the opposing team to advance. In the next 2 rounds it has to win 3 matches.

    The starting brackets are standard:
    1 v 8
    2 v 7
    3 v 6
    4 v 5

    However what happens is that the next brackets are decided upon those that qualified, i.e. the top qualifying team will next face the bottom qualifying team, that could be 1 v 7 or even 5 v 8 with other match being 6 v 7 !

    Your examples so far have been brilliant but what I need to add is both this resorting in the second round and then the more trivial 2-1 or 2-0 etc for each round.

    Anyone have a good method to make this sort correctly, once all the first round matches have been decided upon?

  3. #78
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,091
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Question Clarification please ...

    Quote Originally Posted by Stalfur View Post
    ...
    The format consists of 3 rounds, in the first round a team has to win 2 matches against the opposing team to advance. In the next 2 rounds it has to win 3 matches.

    The starting brackets are standard:
    1 v 8
    2 v 7
    3 v 6
    4 v 5

    However what happens is that the next brackets are decided upon those that qualified, i.e. the top qualifying team will next face the bottom qualifying team, that could be 1 v 7 or even 5 v 8 with other match being 6 v 7 !

    Your examples so far have been brilliant but what I need to add is both this resorting in the second round and then the more trivial 2-1 or 2-0 etc for each round.

    ...
    Can you give a little more specific example of how advancement determines bracket-match combinations? For example:
    Teams:
    Match 1
    1 v 8
    2 v 7
    3 v 6
    4 v 5
    Assuming 8, 7, 6 and 5 win their match, would the next combination be:
    Match 2
    8 v 7
    6 v 5
    1 v 2
    3 v 4
    Assuming 7, 5, 2 and 4 with their match, who advances to the next Round?
    7 and 5 won 2
    8 and 6 won 1 and lost 1
    2 and 4 won 1 and lost 1
    1 and 3 lost 2
    It would appear you have eliminated only two teams from advancement
    Do only 7 and 5 teams advance to the next Round only?

    Then how does Round 2 starting teams get initialize? From a different group of 1-8 teams?

    I am confused as to the requirements and need further clarification.

  4. #79
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Apologies, the first round matches

    1 v 8
    2 v 7
    3 v 6
    4 v 5

    They will play until either team has won 2 games (so 2-3 games)

    Next round will see the winner of these 4 matchups advance. This is where it gets tricky, since the brackets are not set. Instead the highest placed team that advances is matched up against the lowest team that advances.

    So that could be 1,2,3,4 that advance, in that case the two matchups will be
    1 v 4 (highest vs lowest)
    2 v 3

    Or it could be 1,7,3,5, int that case the matchups are
    1 v 7 (highest vs lowest)
    3 v 5

  5. #80
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,962
    Thanks
    79
    Thanked 4,426 Times in 4,391 Posts
    And then the same process for the finals?

    And do you want to be able to record *ALL* scores or *ALL* games, or just the winners of the 2-out-of-3?

    And surely you need to store this in a database or file somewhere? Because if you don't, you'd have to re-enter the scores/wins each time you brought up the page. JavaScript has no capability of "remembering" from one time to the next. (Well, not quite true. Each browser could remember, but if Joe entered scores, Jane could not see them. You need server-side code for that.)

    I really think this question has nothing to do with JavaScript, really. It should be solved via server-side coding. PHP/JSP/ASP/etc.
    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.

  6. #81
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The server side stuff isn't what worries me, this will be in php/mysql, something I'm used to.

    The problem is how to create the new brackets, once the winners of the first brackets (1v8 etc) have been chosen (with a score of 2-1 or 2-0, but that is a seperate field).

    All the javascripts here are based on the brackets being pre-determined, so that winner of 1v8 will meet winner of 4v5. Not the case for me, hence my hiccup at creating this.

  7. #82
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK. I have managed to mash together a prototype which does mostly what I want it to do. (Prototype so it looks horrid, nevermind that)

    http://leikir.betra.is/mytest.html

    Basically after each round the teams are re-ordered so the top will always meet the bottom team.

    EDIT: Two issues:

    1) It works in Firefox 4.0 beta8 and IE but not in Chrome?? If anyone can figure out why it would be helpful!
    2) Once I click on Generate the teams are re-ordered, so if I then have a change of heart and fix a previous score, then both teams in that bracket are in danger of advancing! Any elegant solution to this?

    Also if you spot any obvious failures or ways to make this work smoother, feedback would be appreciated!
    Last edited by Stalfur; 02-20-2011 at 02:22 AM.

  8. #83
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do you know! Managed to sort this out on my own, I'm not sure if I did it elegantly but it works!

    Special thanks to Old Pedant for his bracket posts earlier in the thread, those got me on the right track even if I ended up remaking pretty much everything.

    For those interested in seeing what I clearly wasn't communicating well enough, you can check out this dummy test: http://leikir.betra.is/mytest2.html

  9. #84
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nm, solved it..
    Last edited by dansteidl; 03-08-2011 at 06:26 AM. Reason: solved problem

  10. #85
    New to the CF scene
    Join Date
    Dec 2011
    Location
    NY
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Having trouble making my own bracket website!

    I am not sure if anyone is still using this thread, but I am trying to do this myself and am having issues.

    What I have so far is a bracket that user's can fill out and submit. These values seem to be properly stored in the SQL table that I have created. But here's what I need to do:

    Somehow save the webpage of each bracket so that people can go back to brackets and view them (such as the master/official bracket) or even change their picks.

    Right now, once the bracket is filled in, data is stored in the sql table but the bracket itself disappears forever and the user is redirected to the homepage. Can you be of any assistance? I'd love to share any code that anyone would be willing to look at.

    I would imagine that this issue is on the back end of my bracket webpage, as the front end has been pretty clearly laid out on this forum. I do everything Old Pedant and mbrewer say to do. Here's my back-end (where the bracket form redirects)

    Code:
    <?
    
        // require common code
        require_once("includes/common.php");
        
        // make sure bracket name field is filled
        if(empty($_POST["bracketname"]))
            apologize("Please enter a bracket name!"); 
        
        // escape username to avoid SQL injection attacks
        $bracketname = mysql_real_escape_string($_POST["bracketname"]);
        $pick1_1 = mysql_real_escape_string($_POST["pick1_1"]);
        $pick1_2 = mysql_real_escape_string($_POST["pick1_2"]);
        $pick1_3 = mysql_real_escape_string($_POST["pick1_3"]);
        $pick1_4 = mysql_real_escape_string($_POST["pick1_4"]);
        $pick1_5 = mysql_real_escape_string($_POST["pick1_5"]);
        $pick1_6 = mysql_real_escape_string($_POST["pick1_6"]);
        $pick1_7 = mysql_real_escape_string($_POST["pick1_7"]);
        $pick1_8 = mysql_real_escape_string($_POST["pick1_8"]);
        $pick1_9 = mysql_real_escape_string($_POST["pick1_9"]);
        $pick1_10 = mysql_real_escape_string($_POST["pick1_10"]);
        $pick1_11 = mysql_real_escape_string($_POST["pick1_11"]);
        $pick1_12 = mysql_real_escape_string($_POST["pick1_12"]);
        $pick1_13 = mysql_real_escape_string($_POST["pick1_13"]);
        $pick1_14 = mysql_real_escape_string($_POST["pick1_14"]);
        $pick1_15 = mysql_real_escape_string($_POST["pick1_15"]);
        $pick1_16 = mysql_real_escape_string($_POST["pick1_16"]);
        $pick1_17 = mysql_real_escape_string($_POST["pick1_17"]);
        $pick1_18 = mysql_real_escape_string($_POST["pick1_18"]);
        $pick1_19 = mysql_real_escape_string($_POST["pick1_19"]);
        $pick1_20 = mysql_real_escape_string($_POST["pick1_20"]);
        $pick1_21 = mysql_real_escape_string($_POST["pick1_21"]);
        $pick1_22 = mysql_real_escape_string($_POST["pick1_22"]);
        $pick1_23 = mysql_real_escape_string($_POST["pick1_23"]);
        $pick1_24 = mysql_real_escape_string($_POST["pick1_24"]);
        $pick1_25 = mysql_real_escape_string($_POST["pick1_25"]);
        $pick1_26 = mysql_real_escape_string($_POST["pick1_26"]);
        $pick1_27 = mysql_real_escape_string($_POST["pick1_27"]);
        $pick1_28 = mysql_real_escape_string($_POST["pick1_28"]);
        $pick1_29 = mysql_real_escape_string($_POST["pick1_29"]);
        $pick1_30 = mysql_real_escape_string($_POST["pick1_30"]);
        $pick1_31 = mysql_real_escape_string($_POST["pick1_31"]);
        $pick1_32 = mysql_real_escape_string($_POST["pick1_32"]);
        $pick2_1 = mysql_real_escape_string($_POST["pick2_1"]);
        $pick2_2 = mysql_real_escape_string($_POST["pick2_2"]);
        $pick2_3 = mysql_real_escape_string($_POST["pick2_3"]);
        $pick2_4 = mysql_real_escape_string($_POST["pick2_4"]);
        $pick2_5 = mysql_real_escape_string($_POST["pick2_5"]);
        $pick2_6 = mysql_real_escape_string($_POST["pick2_6"]);
        $pick2_7 = mysql_real_escape_string($_POST["pick2_7"]);
        $pick2_8 = mysql_real_escape_string($_POST["pick2_8"]);
        $pick2_9 = mysql_real_escape_string($_POST["pick2_9"]);
        $pick2_10 = mysql_real_escape_string($_POST["pick2_10"]);
        $pick2_11 = mysql_real_escape_string($_POST["pick2_11"]);
        $pick2_12 = mysql_real_escape_string($_POST["pick2_12"]);
        $pick2_13 = mysql_real_escape_string($_POST["pick2_13"]);
        $pick2_14 = mysql_real_escape_string($_POST["pick2_14"]);
        $pick2_15 = mysql_real_escape_string($_POST["pick2_15"]);
        $pick2_16 = mysql_real_escape_string($_POST["pick2_16"]);
        $pick3_1 = mysql_real_escape_string($_POST["pick3_1"]);
        $pick3_2 = mysql_real_escape_string($_POST["pick3_2"]);
        $pick3_3 = mysql_real_escape_string($_POST["pick3_3"]);
        $pick3_4 = mysql_real_escape_string($_POST["pick3_4"]);
        $pick3_5 = mysql_real_escape_string($_POST["pick3_5"]);
        $pick3_6 = mysql_real_escape_string($_POST["pick3_6"]);
        $pick3_7 = mysql_real_escape_string($_POST["pick3_7"]);
        $pick3_8 = mysql_real_escape_string($_POST["pick3_8"]);
        $pick4_1 = mysql_real_escape_string($_POST["pick4_1"]);
        $pick4_2 = mysql_real_escape_string($_POST["pick4_2"]);
        $pick4_3 = mysql_real_escape_string($_POST["pick4_3"]);
        $pick4_4 = mysql_real_escape_string($_POST["pick4_4"]);
        $pick5_1 = mysql_real_escape_string($_POST["pick5_1"]);
        $pick5_2 = mysql_real_escape_string($_POST["pick5_2"]);
        $pick6_1 = mysql_real_escape_string($_POST["pick6_1"]);
         
             
        // declare ID variable
        $id = $_SESSION["id"];   
       
        // insert user's picks
        $sql = "INSERT INTO picks (id, pick1_1, pick1_2, pick1_3, pick1_4, pick1_5, pick1_6, pick1_7, pick1_8, 
        pick1_9, pick1_10, pick1_11, pick1_12, pick1_13, pick1_14, pick1_15, pick1_16, pick1_17, pick1_18, 
        pick1_19, pick1_20, pick1_21, pick1_22, pick1_23, pick1_24, pick1_25, pick1_26, pick1_27, pick1_28, 
        pick1_29, pick1_30, pick1_31, pick1_32, pick2_1, pick2_2, pick2_3, pick2_4, pick2_5, pick2_6, 
        pick2_7, pick2_8, pick2_9, pick2_10, pick2_11, pick2_12, pick2_13, pick2_14, pick2_15, 
        pick2_16, pick3_1, pick3_2, pick3_3, pick3_4, pick3_5, pick3_6, pick3_7, pick3_8, pick4_1, 
        pick4_2, pick4_3, pick4_4, pick5_1, pick5_2, pick6_1, bracketname) VALUES ('$id', '$pick1_1', '$pick1_2', '$pick1_3', '$pick1_4', 
        '$pick1_5', '$pick1_6', '$pick1_7', '$pick1_8', '$pick1_9', '$pick1_10', '$pick1_11', '$pick1_12', 
        '$pick1_13', '$pick1_14', '$pick1_15', '$pick1_16', '$pick1_17', '$pick1_18', '$pick1_19', '$pick1_20', 
        '$pick1_21', '$pick1_22', '$pick1_23', '$pick1_24', '$pick1_25', '$pick1_26', '$pick1_27', '$pick1_28', 
        '$pick1_29', '$pick1_30', '$pick1_31', '$pick1_32', '$pick2_1', '$pick2_2', '$pick2_3', '$pick2_4', 
        '$pick2_5', '$pick2_6', '$pick2_7', '$pick2_8', '$pick2_9', '$pick2_10', '$pick2_11', '$pick2_12', 
        '$pick2_13', '$pick2_14', '$pick2_15', '$pick2_16', '$pick3_1', '$pick3_2', '$pick3_3', '$pick3_4', 
        '$pick3_5', '$pick3_6', '$pick3_7', '$pick3_8', '$pick4_1', '$pick4_2', '$pick4_3', '$pick4_4', 
        '$pick5_1', '$pick5_2', '$pick6_1', '$bracketname')";
        
        $result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
        $row = mysql_fetch_array($result);
        if (!$result)
                apologize("Internal ERROR 1");
        
        // redirect to homepage
        redirect("index2.php");
        
    
    ?>
    Thank you,
    Andrew

  11. #86
    New Coder
    Join Date
    Mar 2009
    Location
    Bakersfield, CA
    Posts
    18
    Thanks
    0
    Thanked 1 Time in 1 Post
    Can you send me the URL of this page so i can see exactly what's going on? Thanks.

  12. #87
    New to the CF scene
    Join Date
    Dec 2011
    Location
    NY
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    URL of this webpage is...

    http://www.codingforums.com/showthre...=160272&page=6

    and the general URL for the thread is

    http://codingforums.com/javascript-programming/160272-ncaa-tournament-bracket-script.html

    is that what you were looking for in your question

    Can you send me the URL of this page so i can see exactly what's going on? Thanks.

  13. #88
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    He means the URL of your website page!

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  14. #89
    New to the CF scene
    Join Date
    Dec 2011
    Location
    NY
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    haha whoops.

    my website lives here:
    https://cloud.cs50.net/~akcohen/FinalProject

    registering for an account is very painless, you then get directed to a homepage where you can click on a button "create bracket". you then get taken to

    https://cloud.cs50.net/~akcohen/Fina...t/bracket2.php

    where you fill out your bracket and submit your picks. once you submit your picks the picks are stored in an sql database, but i have no way of saving the brackets so that they can be revisited

  15. #90
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,962
    Thanks
    79
    Thanked 4,426 Times in 4,391 Posts
    Pardon me, but this is a *TERRIBLE* database design.

    You are making the PHP code so much more complicated by treating your MySQL database as capable of nothing more than being a spreadsheet.

    You really need to learn about NORMALIZATION. It could simplify this code a lot.
    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.


 
Page 6 of 7 FirstFirst ... 4567 LastLast

Tags for this Thread

Posting Permissions

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