0

how can i call this js function that is inside the method in an onclick on the button that is inside another method

<?php

class Test
{
    public function GetTest()
    {

       print $HTML = '<button onclick="$this->JavaScript( TestJS() )">OK</button>';                

    }

    public function JavaScript( $JS )
    {
        echo '
            <script>
                function TestJS() {
                    alert ("OK!");
                }
            </script>
        ';
    }
}
mehid
  • 47
  • 6
  • this is server side, your code only output flux on your browser, the syntax $this-> in your string doesn't make sense... use only onclick="TestJS()" – Eric Oct 20 '19 at 05:24
  • Possible duplicate of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – Progman Oct 20 '19 at 07:48
  • @Eric I will pass id from the database to identify which button was clicked and the syntax error – mehid Oct 20 '19 at 09:25

0 Answers0