Click here to Skip to main content
15,889,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i click 1st button first row showing and 2nd button first row data again showing not looping

What I have tried:

<pre> <script type="text/javascript">

        const displayCoordinates = function (coord) {
        document.querySelector('.coord').textContent = coord;
        };

        document.querySelector('.check').addEventListener('click', function () {
        const holder =(document.querySelector('.holder').value);

        displayCoordinates(holder).value;
      });

      </script>

<?php
           foreach ($result as $key => $row) {
                   ?>
           <tr>
               <td><?php echo $row['id']; ?></td>
               <td><?php echo $row['cat']; ?></td>
               <td><?php echo $row['size']; ?></td>
               <td><?php echo $row['material']; ?></td>
               <td> <button class="btn check">Locate</button>
                  <input type="hidden" class="holder" value="<?php echo $row['lat'].','. $row['lon']; ?>" />
               </td>
           </tr>
       <?php
            }
       ?>
Posted
Updated 5-Aug-22 17:58pm
v2
Comments
Richard MacCutchan 6-Aug-22 7:16am    
You need to check the contents of $result. Although I am not sure exactly what you are trying to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900