我想在php中使用javascript创建动态下拉列表。我能够从下拉列表中获取值并显示第二个列表值。但是,该列表会显示在下一页上。我如何让它显示在同一页面上?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