give value to form element after select event - value should be catched with JQuery I'm pretty new with Drupal &amp; JQuery. I post this question because I was not able to find a solution in the net.

I have a select form element to choose a country. This select displays de country names but keeps the country_code because this is the value to be stored in the DDBB once the form submitted. This select element is linked to ajax because there is a second select field which should show values depending on the selected country.

As soon as the complete address is introduced, JQuery should show a map with the location of the entered address. For that reason I need JQuery to access the country name before the form is submitted.

There is a function that returns the country name for a given country_code but I do not know how to run that function so that the result can be catched by JQuery. One solution would be keep the country_name instead of the country_code (in the select element) but then , into the submit function of the form, I would need a function to get the country code and I would like to avoid this.

$country_list=get_country_list();

$form['c_pais'] = array(
'#title' =&gt; t('Address - Country'),
'#type' =&gt; 'select',
'#options' =&gt; $country_list,
'#required' =&gt; TRUE, 
'#default_value' =&gt; $value_country,
'#ajax' =&gt; array(
    'event' =&gt; 'change',
    'callback' =&gt; 'call_region1_select',
    'wrapper' =&gt; 'dropdown_region1',
),
);


function get_country_list()
{
    db_set_active('mydb');
    $result=db_select('country_list')
    -&gt;fields('country_list',array('country_id','country_name')) 
    -&gt;orderBy('country_name','ASC')
    -&gt;execute();
    $llista_paisos['0']='--- chosse a country ----';
    while($node = $result-&gt;fetchAssoc()) 
    {
        $llista_paisos[$node['country_id']]=$node['country_name'];
    }
    db_set_active();
    //print_r($llista_paisos);
    return $llista_paisos;
}
Use like this to get form select list element in jQuery.

$("#elementId :selected").text() //the text content of the selected option(country name)
$("#elementId").val() //the value of the selected option(country code)