Return to Snippet

Revision: 56107
at March 10, 2012 03:17 by Narayon


Initial Code
<script type="text/javascript">
    document.getElementByID('submitButton').onclick = function() {
        var movies = <?php echo json_encode($movies); ?>;
        showMovies(movies);
    };
</script>
...
<input type="submit" value="Test JavaScript" id="submitButton">

Initial URL
http://stackoverflow.com/questions/6502107/how-to-pass-php-array-parameter-to-javascript-function/6502154#6502154

Initial Description
Writing an PHP array in a javascript file with json_encode.

Initial Title
Pass PHP array parameter to Javascript Function

Initial Tags
javascript, php, array, json

Initial Language
PHP