Generate javascript based on php variable?

Discussion in 'PHP' started by 123GoToAndPlay, Nov 10, 2009.

  1. #1
    Hi all,

    How do i generate javascript depending on a php variable, like

    
    jQuery(document).ready(function() {
    	enableCarousel();
    	
    	checkAgreed();
    -->here php variable if true
    include this javascript
    -->end if
    
    });
    
    
    Code (markup):
    regards,
     
    123GoToAndPlay, Nov 10, 2009 IP
  2. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    solved by
    
    jQuery(document).ready(function() {
    	enableCarousel();
    	checkAgreed();
    	<?php 
    	if(product() == true){
    	ob_start(); ?>
    
    	here a bunch of javascript
    	
    <?PHP $output = ob_get_contents(); ob_end_clean();
    	echo $output;
    	}//endif
    	?>
    });
    
    Code (markup):
    ps: was planning to use heredoc but it wouldn't work :(
     
    Last edited: Nov 10, 2009
    123GoToAndPlay, Nov 10, 2009 IP