How to pass PHP array parameter to Javascript Function???
Posted
by
Son of Man
on Stack Overflow
See other posts from Stack Overflow
or by Son of Man
Published on 2011-06-28T05:46:23Z
Indexed on
2011/06/28
8:22 UTC
Read the original article
Hit count: 194
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...
© Stack Overflow or respective owner