I do not know if this is possible but on this page I have this code below:
$moduleHTML = "";
while($sqlstmt->fetch()) {
$moduleHTML .= "<option value='$dbModuleId'>" . $dbModuleId . " - " . $dbModuleName . "</option>".PHP_EOL;
$outputmodule = "";
$outputmodule .= "<p><strong>Module:</strong> " . $dbModuleId . " - " . $dbModuleName . "</p>";
}
But I want to echo the variable $outputmodule in another page. So below is the code for the other page which included the ajax which links the the script above (module.php) and where it contains the echo and where it contains part of the module drop down menu:
<script type="text/javascript">
function getModules() {
var course = jQuery("#coursesDrop").val();
jQuery('#modulesDrop').empty();
jQuery('#modulesDrop').html('<option value="">Please Select</option>');
jQuery.ajax({
type: "post",
url: "module.php",
data: { course:course },
success: function(response){
jQuery('#modulesDrop').append(response);
}
});
}
</script>
...
<?
$moduleHTML = "";
$moduleHTML .= '<select name="modules" id="modulesDrop">'.PHP_EOL;
$moduleHTML .= '<option value="">Please Select</option>'.PHP_EOL;
$moduleHTML .= '</select>';
echo $outputmodule;
...
Problem is that I am receiving an undefined error for the echo above. My question is that how can I echo the $dbModuleId and $dbModuleName from the module.php page into the editsession.php page (script above)?
if you dont want to use sessions you could pass back your values as a json array then decode it and append your values with jquery
Then on your page