JavaScriptで動的ドロップダウンリストをPHPで作成しようとしています。私はドロップダウンリストから値を取得し、2番目のリスト値を表示することができます。ただし、そのリストは次のページに表示されます。どのようにして同じページに表示させるのですか?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