I am trying to create dynamic drop down lists in php using javascript. I am able to get the value from the dropdown list and display the second list values. However, that list gets displayed on the next page. How do i get it to display on the same page?
This is on the form page:
$(document).ready(course_selectbox_change);
function course_selectbox_change() {
$('#course').change(update_section_list);
}
function update_section_list() {
var course=$('#course').attr('value');
$.get('hashtag.php?course='+course, generateSelect);
}
function show_sections(sections) {
$('#section').html(sections);
}
<?php
include "database.php";
$course= ($_REQUEST['course']);
$semester = ($_REQUEST['semester']);
if (isset($course)) {
$sections = retrieveSection($course);
}
if (!$sections) {
echo 'Select a course first';
} else {
echo '<select name="section"><option>'
. join('</option><option>', $sections)
. '</select>';
}
?>
generateSelectfunction you are calling in your$.get