Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamically fadeIn html based upon values
    primarykey
    data
    text
    <p>I'm using jquery to dynamically fadeIn content based upon the winners of a basketball series. So, for example, lets take the NBA eastern conference finals. It's a best of seven series. First team to win four games wins the series. So, if for the first input tag, the user selects the Chicago Bulls as their winner. For the second game, the user selects the Miami Heat as their winner. Based upon those results so far, jquery will have to fadeIn an additional input tag because obviously the series is going to at least 5 games.</p> <p>That much is very basic. But, would anyone have some food for thought as to how to go about doing this so that if the client was to go back and edit the the winners of the games, it would fade them in and out accordingly. I can do this using lots of conditional statements, but I'd really love to get some food for thought as it relates to a more efficient approach.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ var data = &lt;?php echo $teamone_ac; ?&gt;; var soulja = &lt;?php echo $teamtwo_ac; ?&gt;; var away_team_other = $('.away_team_other').html(); var home_team_other = $('.home_team_other').html(); var away_team_wild = $('.away_team_wild').html(); var home_team_wild = $('.home_team_wild').html(); $("#game_one_other").autocomplete({ source: data }); $("#game_two_other").autocomplete({ source: data, select: function(event, ui) { var game_one_other = $('#game_one_other').val(); var game_two_other = ui.item.value; var game_three_other = $('#game_two_other').val(); var arr = [game_one_other, game_two_other, game_three_other, game_four_other, game_five_other]; var away = away_team_other; var home = away_home_other; var numAway = $.grep(arr, function (elem) { return elem === away; }).length; var numHome = $.grep(arr, function (elem) { return elem === home; }).length; if(game_one_other != game_two_other) { $('#one_four').fadeIn('slow'); } } }); $("#game_three_other").autocomplete({ source: data, select: function(event, ui) { var game_one_other = $('#game_one_other').val(); var game_two_other = $('#game_two_other').val(); var game_three_other = ui.item.value; if(game_two_other == game_three_other &amp;&amp; game_two_other != game_one_other) { $('#one_four').fadeIn('slow'); } } }); $("#game_one_wild").autocomplete({ source: soulja }); $("#game_two_wild").autocomplete({ source: soulja }); $("#game_three_wild").autocomplete({ source: soulja }); $('#one_four').hide(); $('#one_five').hide(); $('#two_four').hide(); $('#two_five').hide(); }); </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload