在下面的代码中我使用了javascript和codeigniter,codeigniter下拉列表没有调用student_detail_view中的javascript函数:当我将js文件放在学生更新文件中时调用它。我试过但我无法得到预期的结果。请任何人帮我解决问题。
查看:student_detail_view:
<script>
function get_subject(index) {
alert ("enter firstMAIN");
var course_name = jQuery('#course_code_id'+index).val();
alert("course_name"+course_name);
var exam_name = jQuery('#exam_name_id').val();
var subject_code = jQuery('#subject_code_id'+index).val();
alert(subject_code);
jQuery.ajax({
data: 'exam_name='+exam_name+'&course_name=' + course_name,
type: 'POST',
url: 'student_site/subject_list ',
success: function(data){
console.log(data);
}
});
}
</script>
<td >
<?php
$js = 'class="dropdown_class" id="course_code_id'.$row->id.'" onChange="get_subject('.$row->id.')" ';
$js_name = 'course_code_id'.$row->id;
echo form_dropdown($js_name, $data, $row->course_code, $js);
echo"hai";
var_dump ($row->course_code);
?>
</td>
<td>
<?php
$js = 'class="dropdown_class" id="subject_code_id'.$row->id.'"';
$js_name = 'subject_code_id'.$row->id;
echo form_dropdown($js_name, $subject_data, $row->subject_code, $js);
?>
</td>
<input type="hidden" name="index" id="index" value="<?php echo $row->id; ?>"/>
查看:Student_update
<script>
function get_subject(index) {
alert ("enter firstMAIN");
var course_name = jQuery('#course_code_id'+index).val();
alert("course_name"+course_name);
var exam_name = jQuery('#exam_name_id').val();
var subject_code = jQuery('#subject_code_id'+index).val();
alert(subject_code);
jQuery.ajax({
data: 'exam_name='+exam_name+'&course_name=' + course_name,
type: 'POST',
url: 'student_site/subject_list ',
success: function(data){
console.log(data);
}
});
}
</script>