0

I am trying to get a loop in php working, sadly, it does not do what it has to do, it quite loops the arrays etc, but when I click on button nothing happens. only the first button works.

here it goes:

     <script>

  $(function() {

    $( "#datepicker" ).datepicker();

  });

  </script>

so far the JS ^ nog the php. not posting entire code. because its quite long but here starts the for each, wich works completly.

echo    "<table>
                        <thead>
                        <tr>
                        <td>Name</td>
                        <td>Last Name</td>
                        <td>Email</td>      
                        <td>Extension</td>
                        <td>Numbers</td>
                        <td>Datum</td>
                        </tr>";     

            foreach ($response as $key => $value) {

                echo "
                    <tr>
                    <td>".$value['fname']."</td>
                    <td>".$value['lname']."</td>
                    <td>".$value['email']."</td>
                    <td>".$value['ext']."</td>
                    "; 
                foreach ($value['numbers'] as $key2 => $numvalue) {
                echo"<td>".$numvalue."</td>";

                }
                echo "<td>";
                echo("<form action='<?php echo" . $_SERVER['PHP_SELF'] . "?>' method='post'> <input type='button' name='button' id='datepicker' value='Get call history'></form>");
                echo "</td>";
            }


                echo "
                    </tr>
                    </thead>
                    </table> "; 

I suppose there is a problem right here:

echo("<form action='<?php echo" . $_SERVER['PHP_SELF'] . "?>' method='post'> <input type='button' name='button' id='datepicker' value='Get call history'></form>");

Sorry for long code..

7
  • You're already in PHP. Remove the <?php echo and ?> from it. Commented Jan 8, 2015 at 15:26
  • 2
    ids need to be unique. Commented Jan 8, 2015 at 15:26
  • I know Ids has to be unique, thats why I am stuck on this. there must be something what I can do about this Commented Jan 8, 2015 at 15:31
  • Change ID to class, and use ".datepicker" in your Javascript Commented Jan 8, 2015 at 15:33
  • Never mind what I said then. Leave it in. What was I thinking; silly me. Commented Jan 8, 2015 at 15:33

1 Answer 1

1

After all I find the right answer, had indeed to change it into a class thanks for that Tom Hart

  $(function() {

$(".datepick2").datepicker({'dateFormat': 'd/m/y'});

  });

  </script>

and the form

echo("<form action='" . $_SERVER['PHP_SELF'] . ">' method='post'> <input type='button' name='button' class='datepick2' value='Get call history'></form>");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.