0
在下面笨代碼我已放置在控制器,型號和視圖一部分。我的目標是如果我從下拉列表中選擇考試名稱,它應該提醒所選的exam
。我的實際結果是,如果我選擇考試名稱,它會引發「海」警報味精而不是考試名稱。請解決我的問題。所選的值應顯示警報MSG
控制器:
public function index()
{
//echo "inside form upload";
$data = array();
//$college_name = $this->session->userdata('college_name');
if($query = $this->import_model->get_exam_data())
{
$data['exam_data'] = $query;
}
//$this->load->view('student_view', $data);
$this->load->view('form_upload',$data);
}
模型:
function get_exam_data()
{
$this->db->distinct();
$this->db->select("CONCAT(exam_name) AS fullexamname", FALSE);//this will concat the value
//$this->db->where('college_name',$college_name);
$query = $this->db->get('examcourse');
return $query->result();
}
視圖:
<script type="text/javascript" charset="utf-8">
function get_subjectcodedetails() {
alert("hai");
//var course_name = jQuery('#course_name_id').val();
var exam_name = jQuery('#exam_name_id').val();
//alert("course_name"+course_name);
alert("exam_name"+exam_name);
jQuery.ajax({
data: '&exam_name='+exam_name,
type: 'POST',
url: 'import/subjectcodedetails',
success: function(data){
//alert("inside change"+data);
console.log(data);
jQuery('#ssubject_code').html(data);
}
});
}
</script>
<form action="http://localhost/CodeIgniter/index.php/import/upload" method="post" accept-charset="utf-8" enctype="multipart/form-data"> <?php
$data = array();
$data["Select Exam Name"] = "Select Exam Name";
foreach ($exam_data as $row)
{
$data[$row->fullexamname] = $row->fullexamname;
}
echo form_dropdown('exam_name', $data, 'small', 'class="dropdown_class" id="exam_name_id" onChange="get_subjectcodedetails()"');
?>
<div id="ssubject_code">