chcę zastosować funkcję function toggle_visibility(id) (JS) w PHP.
Niestety proste przepisanie z html (działającego) z wykorzystaniem echo nie działa - nie wiem jak to poprawnie przejąć.
otrzymany błąd:
Parse error: syntax error, unexpected 'foo' (T_STRING), expecting ';' or ',' in C:\xampp\htdocs\pokazdiv\index.php on line 22
pliki PHP oraz html (wklejam całość bo duże nie są)
<!DOCTYPE HTML> <html lang="pl"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <link rel="stylesheet" href="style.css" type="text/css" /> <title>strona testowa</title> <meta name="format-detection" content="telephone=no"> </head> <script type="text/javascript"> function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == 'none') e.style.display = 'block'; else e.style.display = 'none'; } </script> <body> <?php echo '<div id="foo" style="display:none;"><a href="" onclick="toggle_visibility('foo');">test działania'; ?> </body> </html>
<!DOCTYPE HTML> <html lang="pl"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <link rel="stylesheet" href="style.css" type="text/css" /> <meta name="format-detection" content="telephone=no"> </head> <script type="text/javascript"> function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == 'none') e.style.display = 'block'; else e.style.display = 'none'; } </script> <body> <div id="container"> </div> </body> </html>
z góry dziękuję za pomoc
Pozdrawiam
MS