doudiao2335 2015-06-30 00:27
浏览 18

根据更改时间和天数禁用<option>元素

If you look at my code below, you see a Select Option with all NFL teams as options and IF statements disabling them in certain conditions.

I would like to disable teams based on what days they play during the season.

For example, if two teams play Monday at 8:00pm then I want those two teams disabled at 7:00pm until Wednesday at 6:00am or Sunday at 1:00pm to 6:00am Wednesday etc.

My problem is the day/time each team plays changes every week. I'm not sure how to set this up to automatically know which teams to disable. What I have now is a manual setup where I will change when each team disables each week using "strtotime()". Not sure if this is the best way, some clarification would help!

<?php
    $tt = date("h"); // hours 1-12
    $current = date("h:i:sa"); // Current time of day
    $sundayaftr = strtotime("3:00pm Sunday"); 
    $sundaymorn = strtotime("12:00pm Sunday");
    $thurs = strtotime("7:00pm Thursday");
    $mon = strtotime("7:00pm Monday");
    $start = strtotime("6:00am Wednesday");
    $close = strtotime("8:00pm Sunday");

    // Locks option based on condition
    if(($current >= $thurs) && ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="wr"'.$dis.'>Washington Redskins</option>';
    if(($current >= $mon) && ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nyg"'.$dis.'>New York Giants</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="pe"'.$dis.'>Philadelphia Eagles</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="dc"'.$dis.'>Dallas Cowboys</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="br"'.$dis.'>Baltimore Ravens</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ps"'.$dis.'>Pittsburgh Steelers</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="tt"'.$dis.'>Tennessee Titans</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="gbp"'.$dis.'>Green Bay Packers</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ss"'.$dis.'>Seattle Seahawks</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cbr"'.$dis.'>Cleveland Browns</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="bb"'.$dis.'>Buffalo Bills</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="jj"'.$dis.'>Jacksonville Jaguars</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ic"'.$dis.'>Indianapolis Colts</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ht"'.$dis.'>Houston Texans</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="kcc"'.$dis.'>Kansas City Chiefs</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="md"'.$dis.'>Miami Dolphins</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nep"'.$dis.'>New England Patriots</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nyj"'.$dis.'>New York Jets</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="slr"'.$dis.'>Saint Louis Rams</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nos"'.$dis.'>New Orleans Saints</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="mv"'.$dis.'>Minnesota Vikings</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="tbb"'.$dis.'>Tampa Bay Buccaneers</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ac"'.$dis.'>Arizona Cardinals</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="af"'.$dis.'>Atlanta Falcons</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="sf49"'.$dis.'>San Francisco 49ers</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="sdc"'.$dis.'>San Diego Chargers</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="or"'.$dis.'>Oakland Raiders</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="db"'.$dis.'>Denver Broncos</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cbe"'.$dis.'>Cincinnati Bengals</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cp"'.$dis.'>Carolina Panthers</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="dl"'.$dis.'>Detroit Lions</option>';
    if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cbea"'.$dis.'>Chicago Bears</option>';
    ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?