I don't 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 repeat the $outputmodule variable on another page. So, below is the code for another page, including ajax, which links 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; ...
The problem is that I get an undefined error for the echo above. My question is, how can I echo the $dbModuleId and $dbModuleName from the module.php page to the editsession.php page (script above)?
source share