user4433485
user4433485

Reputation:

PHP loop through form with button ID

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..

Upvotes: 0

Views: 186

Answers (1)

user4433485
user4433485

Reputation:

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>");

Upvotes: 1

Related Questions