title: My variables aren't passing to the function
body: <p>UPDATE: Ali helped me get the values populating, but the issue now is that it's pulling the data from the last game option in the array every time. I need to click the game and show the info for that game. I've updated my code below.</p>
  <p>ORIGINAL: I'm trying to fix a page that contains a form to search for nearby games and display the results. Once the results are displayed, I need to be able to click the results to show information for each of the games in a pop up window.</p>
  <p>It is currently using the default values of the form to populate the popups, eg every club will show 6.15 as the time until I change the time of the search form, in which case they will all show that time as the time of the game within the pop up.</p>
  <p>This is the code used to display the games:</p>
  <pre><code>&lt;div class=&quot;game-search-result-outer pop-profile-view pop-profile-view1&quot;&gt;
      &lt;ul&gt;
           &lt;?php  $src_game = '';
             if(!empty($game_lists)){
              foreach($game_lists as $glist){  
                 if($glist-&gt;count_golfer_join &lt; $glist-&gt;golfer){  
                  ?&gt;
                  &lt;li class=&quot;game&lt;?=$glist-&gt;id?&gt;&quot; onclick=&quot;getGameValue('&lt;?=$glist-&gt;id?&gt;','&lt;?=$glist-&gt;club_name?&gt;','&lt;?=$src_game?&gt;','&lt;?=$glist-&gt;handicap_min?&gt;','&lt;?=$glist-&gt;handicap_max?&gt;','&lt;?= date(&quot;d/m/Y&quot;,strtotime($glist-&gt;start_date))?&gt;');&quot;&gt;
                      &lt;a href=&quot;#&quot; data-id=&quot;&lt;?=$glist-&gt;id?&gt;&quot;&gt;
                          &lt;div class=&quot;club-img&quot;&gt;
                              &lt;img src=&quot;&lt;?=$src_game?&gt;&quot;&gt;
                          &lt;/div&gt;
                          &lt;h3&gt;&lt;?=$glist-&gt;club_name?&gt; &lt;br&gt; &lt;?= date(&quot;d/m/Y&quot;,strtotime($glist-&gt;start_date))?&gt; at &lt;?= date(&quot;G:i a&quot;,strtotime($glist-&gt;start_time))?&gt; &lt;br&gt; Handicap between &lt;?=$glist-&gt;handicap_min?&gt; and &lt;?=$glist-&gt;handicap_max?&gt;&lt;/h3&gt;
                      &lt;/a&gt;
                      &lt;input type=&quot;hidden&quot; name=&quot;start_date&lt;?=$glist-&gt;id?&gt;&quot; id=&quot;start_date&lt;?=$glist-&gt;id?&gt;&quot; value=&quot;&lt;?= date(&quot;d/m/Y&quot;,strtotime($glist-&gt;start_date))?&gt;&quot;&gt;
                  &lt;/li&gt;
           &lt;?php }
             } }else{ echo &quot;No Games Available, please refine your search&quot; ;}                              ?&gt;
           
          &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Onclick, it activates this function:</p>
  <pre><code>&lt;script&gt;
  
  function getGameValue(game_id,club_name,src,handicap_min,handicap_max) {
       var golf_handicap = '&lt;?=$USERDETAILS-&gt;golf_handicap?&gt;';    
       var start_date = $(&quot;#start_date&quot;+game_id).val();
       //var start_date = '&lt;?= date(&quot;d/m/Y&quot;,strtotime($glist-&gt;start_date))?&gt;';
       var play_against = $(&quot;#play_against option:selected&quot;).text();
       var start_time = '&lt;?= date(&quot;G:i a&quot;,strtotime($glist-&gt;start_time))?&gt;';
       var handicap1 = $(&quot;#handicap1&quot;).val();
       var gofer = $(&quot;input[name='golfer']:checked&quot;).val();
       var handicapRange1 = handicap_min;                  
       var handicapRange2 = handicap_max; 
       var p = $('.game'+game_id+' &gt; h3');
       
       if(golf_handicap&lt;handicapRange1 || golf_handicap&gt;handicapRange2){
           alert(&quot;Unfortunately you cannot join this game, your handicap &quot;+golf_handicap+&quot; is not within the handicap range.&quot;);
          
           document.location.reload();
           return false
       }  
        
      var data ='&lt;div class=&quot;result-pop-box-img&quot;&gt;&lt;img src=&quot;'+src+'&quot;&gt;&lt;/div&gt;&lt;div class=&quot;result-pop-box-text&quot;&gt;&lt;h3&gt;'+club_name+'&lt;/h3&gt;&lt;p class=&quot;game&lt;?=$glist-&gt;id?&gt;&quot;&gt;Hi &lt;?=$USERDETAILS-&gt;first_name?&gt;, you\’re about to join a game at '+club_name+' on '+ start_date +' at '+ start_time +' for '+ gofer +' golfers playing against '+ play_against +' with a handicap between '+ handicap1 +'. If this is correct, click the “Confirm” button. If you want to edit your booking, click cancel&lt;/p&gt;&lt;/div&gt;'; 
       $(&quot;#getGameValueID&quot;).html(data);
       
  }
  
  &lt;/script&gt;
  </code></pre>
  <p>Thank you for any help.</p>
  <p>UPDATE</p>
  <p>Here is the code for the form:</p>
  <pre><code>&lt;form&gt;
      &lt;div class=&quot;form-control&quot;&gt;
      &lt;label&gt;Location
         &lt;?php  $zip = ($USERDETAILS-&gt;s_address)?', '.$USERDETAILS-&gt;zip:''.$USERDETAILS-&gt;zip;
         $location = $USERDETAILS-&gt;s_address.$zip;  ?&gt;
          &lt;span class=&quot;loc-icon&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;location&quot; class=&quot;icon-input&quot; id=&quot;location&quot; value=&quot;&lt;?=$location?&gt;&quot;&gt;&lt;/span&gt; 
      &lt;/label&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-control&quot;&gt; 
      &lt;label&gt;Date
          &lt;span class=&quot;cal-icon&quot;&gt;
          &lt;div&gt;
              &lt;!--&lt;input type=&quot;text&quot; id=&quot;datepicker&quot; name=&quot;start_date&quot;&gt;--&gt;
              &lt;input type=&quot;date&quot; id=&quot;start_date2&quot; name=&quot;start_date2&quot; value=&quot;&lt;?php if($_GET['start_date2']){echo $_GET['start_date2'];}else { echo date(&quot;Y-m-d&quot;,strtotime('+1 day', time()));} ?&gt;&quot; min=&quot;&lt;?=date(&quot;Y-m-d&quot;,strtotime('+1 day', time()))?&gt;&quot;  max=&quot;&lt;?=date(&quot;Y-m-d&quot;,strtotime('+1 year', time()))?&gt;&quot;&gt;
          &lt;/div&gt;
          &lt;/span&gt;
          &lt;!--&lt;input type=&quot;text&quot; name=&quot;date&quot; class=&quot;icon-input&quot;&gt;&lt;/span&gt;--&gt;
      &lt;/label&gt;
      &lt;/div&gt;                                
      &lt;div class=&quot;golfer-select&quot;&gt;
          &lt;div class=&quot;form-control&quot;&gt;
              &lt;label&gt;Golfers&lt;/label&gt;
              &lt;?php if($_GET['golfer']==1) $gcheck = 'checked';
                    elseif($_GET['golfer']==2) $gcheck2 = 'checked';
                    elseif($_GET['golfer']==3) $gcheck3 = 'checked';
  
              ?&gt;
              &lt;div class=&quot;x3&quot;&gt;
                  &lt;label&gt;
                  &lt;input type=&quot;radio&quot; name=&quot;golfer&quot; value=&quot;1&quot; &lt;?=$gcheck?&gt;&gt;
                  &lt;span&gt;1&lt;/span&gt;
                  &lt;/label&gt;
              &lt;/div&gt;
              &lt;div class=&quot;x3&quot;&gt;
                  &lt;label&gt;
                  &lt;input type=&quot;radio&quot; name=&quot;golfer&quot; value=&quot;2&quot; &lt;?=$gcheck2?&gt;&gt;
                  &lt;span&gt;2&lt;/span&gt;
                  &lt;/label&gt;
              &lt;/div&gt;
              &lt;div class=&quot;x3&quot;&gt;
                  &lt;label&gt;
                      &lt;input type=&quot;radio&quot; name=&quot;golfer&quot; value=&quot;3&quot; &lt;?=$gcheck3?&gt;&gt;
                      &lt;span&gt;3&lt;/span&gt;
                  &lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;                          
      &lt;/div&gt;
      &lt;div class=&quot;form-control&quot;&gt;
      &lt;label&gt;Play Againts&lt;/label&gt;
          &lt;select name=&quot;play_against&quot; id=&quot;play_against&quot;&gt;
              
              &lt;?php foreach($categories as $cate){ 
                      if($_GET['play_against']==$cate-&gt;id) { 
                      $csel = 'selected';
                   }else{ $csel = ''; }
                    ?&gt;
          
                  &lt;option value=&quot;&lt;?=$cate-&gt;id?&gt;&quot;&lt;?=$csel?&gt;&gt;&lt;?=$cate-&gt;name?&gt;&lt;/option&gt;
              &lt;?php } ?&gt;  
          &lt;/select&gt;
      &lt;/div&gt;                                
      
      &lt;div class=&quot;form-control&quot;&gt;
      
          
          &lt;div class=&quot;time-range&quot;&gt;
              &lt;label&gt;Start Time&lt;/label&gt;
              &lt;div class=&quot;range range-step range-step-popup&quot;&gt;
                  &lt;input value=&quot;1&quot; type=&quot;range&quot; max=&quot;60&quot; min=&quot;0&quot; step=&quot;1&quot; list=&quot;ticks2&quot; onclick=&quot;getTimeValue();&quot;&gt;
                  &lt;datalist id=&quot;ticks2&quot;&gt;
                    &lt;?php $minute=00; $counter=0;
                    for($start_time=06;$start_time&lt;21;){
                        
                        if($minute&gt;45){
                          $minute = 00;
                          $start_time++;
                        }?&gt;
                        &lt;option value=&quot;&lt;?=$counter?&gt;&quot;&gt;&lt;?=$start_time?&gt;.&lt;?=$minute?&gt;&lt;/option&gt;
                       &lt;?php 
                       $counter++;
                       $minute= $minute+15;
                        
                    }?&gt;
                    
                    
                    
                  &lt;/datalist&gt;
                  &lt;output id=&quot;get_range&quot; class=&quot;__range-output-square&quot;&gt;&lt;/output&gt;
              &lt;/div&gt;
          
              &lt;input type=&quot;text&quot; name=&quot;start_time&quot; id=&quot;start_time&quot;&gt;
              &lt;script&gt;
              function getTimeValue() {
                  var range_val = document.getElementById('get_range').innerHTML;
                  document.getElementById('start_time').value=range_val;
              }
              &lt;/script&gt;
          &lt;/div&gt;
          
      &lt;/div&gt;
      
      &lt;div class=&quot;form-control&quot;&gt;
      &lt;div class=&quot;dis-range&quot;&gt;
              &lt;label&gt;Distance (in miles)&lt;/label&gt;
              &lt;div class=&quot;range range-step range-step-popup&quot;&gt;
                      &lt;?php  $dist_val = array(0,5,10,15,20,25,30,35,40,50,60,75,100,125,150,200,300,500,1000,2000,3000,5000,10000);
                      
                       if(in_array($_GET['distance'],$dist_val)){
                           $key_val = array_search ($_GET['distance'], $dist_val);
                           $sel_dist_key = $key_val;
                       }else{
                           $sel_dist_key = 15;
                       } ?&gt;
                      &lt;input value=&quot;&lt;?=$sel_dist_key?&gt;&quot; type=&quot;range&quot; max=&quot;22&quot; min=&quot;0&quot; step=&quot;1&quot; list=&quot;ticks3&quot;  onclick=&quot;getValue();&quot;&gt;
                      &lt;datalist id=&quot;ticks3&quot;&gt;
                        &lt;option value=&quot;0&quot;&gt;0&lt;/option&gt;
                        &lt;option value=&quot;1&quot;&gt;5&lt;/option&gt;
                        &lt;option value=&quot;2&quot;&gt;10&lt;/option&gt;
                        &lt;option value=&quot;3&quot;&gt;15&lt;/option&gt;
                        &lt;option value=&quot;4&quot;&gt;20&lt;/option&gt;
                        &lt;option value=&quot;5&quot;&gt;25&lt;/option&gt;
                        &lt;option value=&quot;6&quot;&gt;30&lt;/option&gt;
                        &lt;option value=&quot;7&quot;&gt;35&lt;/option&gt;
                        &lt;option value=&quot;8&quot;&gt;40&lt;/option&gt;
                        &lt;option value=&quot;9&quot;&gt;50&lt;/option&gt;
                        &lt;option value=&quot;10&quot;&gt;60&lt;/option&gt;
                        &lt;option value=&quot;11&quot;&gt;75&lt;/option&gt;
                        &lt;option value=&quot;12&quot;&gt;100&lt;/option&gt;
                        &lt;option value=&quot;13&quot;&gt;125&lt;/option&gt;
                        &lt;option value=&quot;14&quot;&gt;150&lt;/option&gt;
                        &lt;option value=&quot;15&quot;&gt;200&lt;/option&gt;
                        &lt;option value=&quot;16&quot;&gt;300&lt;/option&gt;
                        &lt;option value=&quot;17&quot;&gt;500&lt;/option&gt;
                        &lt;option value=&quot;18&quot;&gt;1000&lt;/option&gt;
                        &lt;option value=&quot;19&quot;&gt;2000&lt;/option&gt;
                        &lt;option value=&quot;20&quot;&gt;3000&lt;/option&gt;
                        &lt;option value=&quot;21&quot;&gt;5000&lt;/option&gt;
                        &lt;option value=&quot;22&quot;&gt;10000&lt;/option&gt;
                      &lt;/datalist&gt;
                      &lt;output id=&quot;get_distance&quot; class=&quot;__range-output-square&quot;&gt;&lt;/output&gt;
              &lt;/div&gt;
              &lt;input type=&quot;hidden&quot; name=&quot;distance&quot; id=&quot;distance&quot; value=&quot;&quot;&gt;
              &lt;script&gt;
              function getValue() {
                  var range_val = document.getElementById('get_distance').innerHTML;
                  document.getElementById('distance').value=range_val;
              }
              &lt;/script&gt;
      &lt;/div&gt;
      
      &lt;/div&gt;
      
      &lt;div class=&quot;form-control&quot;&gt;
      
          &lt;div class=&quot;handi-range&quot;&gt;
              &lt;label&gt;Handicap&lt;/label&gt;
              
               &lt;section class=&quot;range-slider range range-step range-step-popup&quot;&gt;                                       
  
                  &lt;span class=&quot;rangeValues&quot;&gt;&lt;/span&gt;
  
                  &lt;input value=&quot;0&quot; min=&quot;0&quot; max=&quot;54&quot; step=&quot;1&quot; type=&quot;range&quot;&gt;
  
                  &lt;input value=&quot;54&quot; min=&quot;1&quot; max=&quot;54&quot; step=&quot;1&quot; type=&quot;range&quot;&gt;
  
                 &lt;datalist class=&quot;in-dots&quot; id=&quot;&quot;&gt; 
                     &lt;?php for ($handcap=0;$handcap&lt;=54;$handcap++){ 
                       
                       echo '&lt;option value=&quot;'.$handcap.'&quot;&gt;'.$handcap.'&lt;/option&gt;';
                    
                      } ?&gt;
                  &lt;/datalist&gt;
                  
                  
                  &lt;/section&gt;
                  &lt;input type=&quot;hidden&quot; name=&quot;handicap&quot; id=&quot;handicap1&quot;&gt;                                        
                  
  
          &lt;/div&gt;
          
      &lt;/div&gt;
      
      &lt;div class=&quot;sp20&quot;&gt;&lt;/div&gt;
      &lt;input type=&quot;submit&quot; name=&quot;search&quot; value=&quot;Search&quot; class=&quot;green-btn-arrow&quot; onclick=&quot;getInfo();&quot;&gt;
      &lt;!--&lt;button class=&quot;green-btn-arrow&quot;&gt;Search&lt;/button&gt;--&gt;
  &lt;/form&gt;
  </code></pre>