我已在codeigniter视图中使用jquery ajax填充了选项。当我从B
类型中选择Village
时,会填充Category
选择选项,选择District
会向我District
,Tehsils
会给我{{1} }}。问题在于tehsils
选择选项,它会在数据库中插入Union Councils
,但不会插入其实际值。喜欢
union council
。
下面是我的代码和图片。请帮我。感谢。
控制器
None
模型
INSERT INTO 'hazara_tbl' ('HName', 'HDescription', 'Latitude', 'Longitude', 'CatagoryType', 'ParentID') VALUES ('ABC', 'blalbala', '123', '345', 'Village', 'None')
查看
public function create_main()
{
if(!empty($_POST))
{
$this->load->model('insert_data_model');
$query = $this->insert_data_model->add();
$data = $this->db->last_query();
print_r($data);
exit();
redirect('insert_data/index/');
}
else
{
$this->load->model('insert_data_model');
$data['getDistt'] = $this->insert_data_model->getDisttforTehsil();
$this->load->view('insertManual/main_insert', $data);
}
public function getTehsilsForDistt($id="")
{
$new = $_POST['id'];
$id = $this->input->post('HID');
$data['query'] = $this->db->query("SELECT `HID`, `HName` FROM hazara_tbl WHERE `ParentID` = '".$new."' AND `CatagoryType` = 'Tehsil' ")->result();
echo json_encode($data);
}
public function getUCForTehsils($idV="")
{
$newV = $_POST['idV'];
$idV = $this->input->post('HID'); //receiving the ajax post from view
$data['Vquery'] = $this->db->query("SELECT `HID`, `HName` FROM hazara_tbl WHERE `ParentID` = '".$newV."' AND `CatagoryType` = 'Union Council' ")->result();
echo json_encode($data);
}
}