A selection box based on values should appear in text fields,
The current code is functional in local host but not working on the hostgator server
For example, displaying country options based on the selected state and districts based on the selected state.
<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 = [], description = [];
$.each(data, function (key, value) {
title.push(value.page_title);
metatags.push(value.page_metatags);
description.push(value.page_description);
});
$('input[name="city"]').val(title.join(','));
$('input[name="Metatags"]').val(metatags.join(','));
$('input[name="Description"]').val(description.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);
}