dropdown
框应显示在文本字段中,
当前代码在localhost中工作,但不在hostgator服务器上工作
示例国家/地区基于州和州的州/州
<script type="text/javascript">
$(document).ready(function () {
$('#state').on('change', function () {
var stateID = $(this).val();
if (stateID) {
$.ajax({
url: '<?php echo base_url(); ?>index.php/myform/ajax/' + stateID,
type: "GET",
dataType: "json",
success: function (data) {
console.log(data);
var title = [], metatags = [], decription = [];
$.each(data, function (key, value) {
title.push(value.page_title);
metatags.push(value.page_metatags);
decription.push(value.page_decription);
});
$('input[name="city"]').val(title.join(','));
$('input[name="Metatags"]').val(metatags.join(','));
$('input[name="Description"]').val(decription.join(','));
}
});
}
});
});
</script>
routes.php文件
$route['myform'] = 'welcome';
$route['myform/ajax/(:any)'] = 'welcome/myformAjax/$1';
的welcome.php
public function update() {
$this->load->helper('url');
$data['state_fetch'] = $this->Question_Insertion_Model->all_Pages_Display();
$this->load->view('update', $data);
}
public function myformAjax($id) {
$this->db->select('c.*');
$this->db->where("s.page_id", urldecode($id));
$this->db->join('kas_all_pages s', 's.page_id = c.page_fk');
$result = $this->db->get('kas_all_pages_tags c')->result();
echo json_encode($result);
}
答案 0 :(得分:1)
只需添加以下代码