JavaScript - 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> </td> <td> </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> </td> <td> </td> <td> </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> </td> <td> </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> </td> <td> </td> <td> </td> <td> </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> </td> <td> </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> </td> <td> </td> <td> </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> </td> <td> </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> </td> <td> </td> <td> </td> <td> </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: </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> </td> <td> </td> <td> </td> <td> </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> </td> <td> </td> <td> </td> <td> </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... Similar TutorialsHey Everyone, I'm hoping you all can help me with this. I have created a html ncaa tournament bracket for my website in which I hold annual competitions. Recently, my competition has grown and I need a better way for users to submit their brackets. What Im looking for is a way to allow the person filling out the bracket to click on their predicted winner for each game, which will then fill out the bracket as they move through the bracket until the have predicted a national champion. Any Ideas? What is the [0] for? And even better if you can tell me what they're called, in this context; I want to find a tutorial. Tryit Editor v2.1 PHP Code: var a=document.getElementsByTagName("a")[0]; Thanks! Code: <form> <input type="button" value="Click!" id="001" /> </form> function one() { window.alert('Hello'); window.alert('World!'); } var varname=document.getElementById("001"); varname.onclick=one; I am not sure if the last line is this example is correct. Should it not be: varname.onclick=one(); Or is it ok to write it either way? Thanks. |