Welcome Guest, Not a member yet? Register   Sign In
Retrieve selected value from dropdown form populated from DB. Jquery

Hi there, have been working on this problem far too long so have signed up for some help.

I am trying to create a dropdown form with countries populated from a database. I need to get the chosen countries ID and store it into another table on the DB. So far i have created the dropdown but have no idea how to use JQuery to get ID from the list.

Any help would be appreciated.


$attributes = array('class' => 'profile_textbox_disabled', 'id'=> 'country_select', 'disabled' =>'disabled');
echo form_open('', $attributes);
echo form_dropdown('countries', $select_country);
<a href="#" id="country_select_edit"><img src="&lt;?php echo base_url(); ?&gt;assets/images/edit.png" alt="Edit" ></a>
<span id="country_select_ajax_reply" class="notify"></span>
echo form_close();


$("#country_select_edit").click(function () {
.change(function () {

type: "POST",
url: "calls/countries_list/",
//data: "data=" + $(this).val(), //These are other methods i've tried.
//data: "country_name="+$('#country_select').val(), //These are other methods i've tried.
data: "country_name="+this.value+"&id;="+&lt;?php echo $this->session->userdata('user_id'); ?&gt;,
complete: function(data){

//print result in targetDiv

$('#country_select').removeClass('profile_textbox_enabled').attr("disabled", "disabled");



$query = $this->db->query("
SELECT country_id, country_name
FROM countries
foreach($query->result_array() as $row)
return $data;


function countries_list()
$message = $_POST['country_name'];
//echo $_POST['data'];
echo $message;

Am using $message to trial and error the code to try get a value returned. At the moment i keep getting undifined.

Theme © iAndrew 2016 - Forum software by © MyBB