Jump to content

Passing Php Variables Into Javascript


dzhax

Recommended Posts

I have this javascript

<script type="text/javascript">   showhide(!is_group_hidden(1),1);   </script>

I need to change the ones in (1),1 to be dyanmic or changed with php but i can not seem to get it to work.I am databasing my website and making each section show up with a <?php while(...){ statment. At the end of each while (before the closing } ) i have the above script. For each recuring section the 1's need to be changed to 2's then 3's then 4's.I tried:

<script type="text/javascript">   showhide(!is_group_hidden(<?php echo $p1['id'] ?>),<?php echo $p1['id'] ?>);   </script>

But that does nothing. It wont even work for the first one anymore.Any help? Or maybe I should repost in PHP. Not sure.

Link to comment
Share on other sites

I'm not sure what you want to do but just to check - you do realise that php cannot be dynamic on the web page. It is fully resolved and disappears before the page leaves the server? The javascript has no php variables at the time the script is parsed.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...