How to pass PHP array parameter to Javascript Function???
- by Son of Man
index.php
<script type="text/javascript" src="javascript.js"> </script>
<?php
$movies = array("Bloodsport", "Kickboxer", "Cyborg", "Timecop", "Universal Soldier", "In Hell", "The Quest");
?>
<input type="submit" value="Test Javascript" onclick="showMovies(<?php echo $movies; ?>);" />
javascript.js
function showMovies(movies) {
alert(movies.length);
return false;
}
I am new to programming so Im having hard time fixing this one which is obviously simple for you guys.
When I hit the submit button it says the that the array size is 1 which I think should be 7. How could this be??? Pls tell me what to do...
Thanks in Advance...