I a webpage written in php/html that adds the contents of a text box to a session array each time a submit button is pressed. What I need to be able to do is take the unknown number of elements in the session array and have access to each of them in the javascript portion of my code.
Here is the php portion of my code so far:
<?php
session_start();
if(!isset($_SESSION['answers']))
$_SESSION['answers'] = array();
?>
<?php
if (!empty($_POST['submit'])) {
unset($_POST['submit']);
$_SESSION['locations'][] = $_POST;
}
if (!empty($_POST['display'])){
foreach ($_SESSION['locations'] as $array){
echo "<script type='text/javascript'>alert('{$array['lat']}')</script>";
}
}
?>
This will display each as an alert, but I need them as variables that can be accessed in javascript.
Thanks in advance