Value of select in single record form

Need javascipt call to get the value of field ‘FK_country_id’

I will be tying this to a onClick event on a button on top of the form to pre-fill a readonly field (the primary key field ‘region_id’).

This field is a select lookup value to the key field in a related innoDB table within the same database (select look up with primary key being field NOT shown - instead displays country name - I need the key value.)

Obviously the insert record will produce a pre-filled select with the starting record of the related database shown first - this functionality is working perfectly, however I am unable to grab the value.

I am concatenating the country ID (a foreign key) with the region name to make a new key field in the database related to the form shown. I am doing this after validating (region_name !== empty.

Have tried:

var region_name = document.getElementById(“id_sc_field_region_name”).value;
var country_id = document.getElementById(“id_sc_field_FK_country_id”).value;
var region_new = country_id + “-” + region_name;

alert (region_nw);

Will not produce alert.

Have tried with only region_name (a text field) - Alert is produced.

I’m not in front of a PC and I cant help too much right now, but I’m curious. Why you need to be a JS call, when you can create an Ajax event?

I have tried this method also - please try on your pc - a select field ‘onChange’ does not seem to trigger a value unless it is another select.

Try var region_new = String(country_id) + “-” + region_name;