-1

Simple question, but I still cant get my head around different languages being able to communicate with each other in a webpage!

I have a PHP section in my webpage, which links to an SQL database. It retrieves a column of postcode data and stores it in and array called $info.

I then have a javascript function which I want to be able to use the postcodes. How can I access the $info array (PHP) from the JavaScript? Does it have to go into some global array for all to see, or can the javascript access it directly?

0

1 Answer 1

4
<script type="text/javascript">
  alert('<?php echo $myString; ?>');
</script>

It's the other way round that's hard.

PS: JavaScript != Java.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks! ps a simple, lazy typo, edited!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.