0

I have this JavaScript function which toggles the visibility of a certain div:

function showHideDiv(id){
var obj = document.getElementById(id);
if (obj.style.display=="none"){
  obj.style.display='block';
} else if(obj.style.display=="block"){
  obj.style.display='none';
}
}

I have a dynamic div that has the id="pm_message'.$row[0].'". I want to toggle the visibility of this div via the javascript function I mentioned above.

This is my link with the onclick-function:

echo '<h1><a onclick="showHideDiv('showHideDiv("message'.$row[0].'")" class="'.$link_class.'" href="'.$profile_url.'">'.$row['title'].'</a></h1>';

It doesn't work and I get this error message:

PHP Parse error:  syntax error, unexpected '?'
halfer
  • 19,824
  • 17
  • 99
  • 186
drpelz
  • 811
  • 11
  • 43

1 Answers1

6
echo '<h1><a onclick="showHideDiv('.$row[0].')" class="'.$link_class.'" href="'.$profile_url.'">'.$row['title'].'</a></h1>';

It is already in php so you do not need to open another set of php tags.

Danny
  • 1,185
  • 2
  • 12
  • 33