...

View Full Version : simple php to javascript array question



kevinkhan
11-08-2012, 09:59 AM
Hi Guys.
If i have an php array


Array
(
[0] => Array
(
[venue] => Briar Rose
)

)

how do i get values from this array called venues into an array called source in this javascript code


<script>
$(document).ready(function() {
$("input#venue").autocomplete({
source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
});
});
</script>

rnd me
11-08-2012, 01:46 PM
how do i get values from this array called venues into an array called source in this javascript code



<script>
var source = <?php echo json_encode( $venues ); ?> ;
</script>

Dormilich
11-09-2012, 06:14 AM
Hi Guys.
how do i get values from this array called venues into an array called source in this javascript code

like rnd_me showed, only that in JS the inner array is not an array but a plain object.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum