자바 스크립트를 사용하여 php에서 동적 인 드롭 다운 목록을 만들려고합니다. 드롭 다운 목록에서 값을 가져 와서 두 번째 목록 값을 표시 할 수 있습니다. 그러나 그 목록은 다음 페이지에 표시됩니다. 같은 페이지에 표시하려면 어떻게해야합니까?PHP 동적 드롭 다운리스트
$(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>';
}
?>
당신이'$ .get'에 호출하는'generateSelect' 함수를 게시 할 수도 있습니까 – DKSan