How to replace the div content onclick?

Here is my script..
This works perfectly if the call the variable $ssk in the html, but it is not working when i call the variable $cvb.

Please help me out...

<!-- php code start -->
<? 

$cvb='<div id="flashcontent">	
	<script type="text/javascript">
	var so = new SWFObject("player.swf", "sree", "635", "240", "9", "#E7E7E7");
	so.addVariable("p_list", "try.xml");
	so.addParam("allowFullScreen", "true");
	so.write("flashcontent");
	</script>
	</div> ';
	
$ssk='SREE';

?>
<!-- php code end -->


<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
<title>Change div content</title>
	
<style>
/* this is just to add color and look :-)*/
div, a { padding:3px; margin:3px 3px 33px 3px; }
#scriptVars1 { border:1px solid red; width:635px; height:240px; background-color:#EEE;}
</style>

<script>
function changeDivContent( nameOfDiv, newContent )
{
var div = document.getElementById( nameOfDiv );
if( div )
{
div.innerHTML = newContent;
}
}
</script>
	
</head>
<body>
<a href="#" onclick="changeDivContent( 'scriptVars1', '<? echo $ssk; ?>' )">Click here to change the content</a>
	
<div id="scriptVars1">
<br/><br/><br/><br/>
This content should be replaced...
</div>

</body>
</html>

Any help from this forum would be really appreciated.

Wow, I am so confused with what you're doing here.

If you're changing between different movies in Flash you might have more luck creating a Flash loader that loads and displays different movies -- variables passed via javascript or as arguments on page load to the end of the .swf file via (movie.swf?myMovie).

If you're writing the flash object via javascript only once, why not make a function that does that and call it to write innerHTML to a div element on click -- instead of trying to place a javascript function inside a link element.

If you just want to insert a Flash movie with PHP and have it show or hide on a click, why not insert the movie in the html with PHP and use CSS to hide the movie until the link is clicked (CSS: display: none;)

Or am I really missing the point here.

Also, just an FYI, PHP supports the heredoc syntax.

<?php
$cvb = <<<endline
  <div id="flashcontent">	
  <script type="text/javascript">
  var so = new SWFObject("player.swf", "sree", "635", "240", "9", "#E7E7E7");
  so.addVariable("p_list", "try.xml");
  so.addParam("allowFullScreen", "true");
  so.write("flashcontent");
  </script>
  </div>
endline;
?>

which can be kind of nice sometimes for blocks of text.

Tell me what you're trying to do here, and I can help you find a way to do it...

Also...is addParam a new part of the Flash model, or something you've come up with? Just curious, I'm a little out of the Flash loop these days -- no pun intended..

You need to post a little more about what you are trying to do in the DIV on click. Do you want to load Flash?

If so your innerHTML strategy is not the right way to go. If you want to add general DOM content you are also better off using DOM methods rather than innerHTML if you can avoid it.

This article has been dead for over six months. Start a new discussion instead.