Jump to content

Passing Php Variables Into Javascript


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.

Edited by dzhax
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...