I got really confused when trying to get PHP functions into javascript.
In my scenario, I just extract some lines from XML file in PHP and convert it into a table, and the presentation of the whole table is in the function getNews(). Into the function are echo sentences like
 function getNews(){
    $xmlResponse = new SimpleXMLElement('xml.addr',0,TRUE);
    foreach($xmlResponse -> children()as $contents){
        echo "<table id ='news'>";
        echo "<a href='".$links."'>".$contents -> item[$num] -> title."</a>";
HTML tags are involved to build a news table.
Then I was asked to implement a button, when clicking on the button, the button image changes and the table should be shown below. Obviously the onclick function should be written using javascript, when click on it, I need to call the anotherButton() function and show the news table
   echo  "<script>function anotherButton(){
      document.getElementById('news').innerHTML='<div class='newStyle' 
      onclick='anotherButton1()'>click to hide stock news
           <img src='http://image-addr'></div>'; 
             }</script>";
All these things were done in PHP and I need to insert function getNews()
somewhere in the above echo, so how I can put the function in it ?
Thanks in advance.
 
    