I have 4 dropdown selects, all the values in the dropdowns are disabled by default except the first one. The value selected in the first dropdown determines which of the other 3 values will be enabled. This means that of the 3 dropdowns only a value is expected to be selected. The code disables and enables as expected but, of these 3 values I'm unable to get the value of the selected element. How do I please help out.
var selectedStoredValue = "";
$(document).ready(function() {
$('select#goodopt').find('option').each(function() {
$(this).prop('disabled', true);
});
$('select#effectiveopt').find('option').each(function() {
$(this).prop('disabled', true);
});
$('select#socialopt').find('option').each(function() {
$(this).prop('disabled', true);
});
$("#producttype").change(function() {
if ($("#producttype").prop('selectedIndex') == "1") {
$('select#goodopt').find('option').each(function() {
$(this).prop('disabled', false);
});
} else {
$('select#goodopt').find('option').each(function() {
$(this).prop('disabled', true);
selectedStoredValue = "";
});
}
});
$("#producttype").change(function() {
if ($("#producttype").prop('selectedIndex') == "2") {
$('select#effectiveopt').find('option').each(function() {
$(this).prop('disabled', false);
selectedStoredValue = $("#effectiveopt option:selected").text();
});
} else {
$('select#effectiveopt').find('option').each(function() {
$('#effectiveopt').val('');
$(this).prop('disabled', true);
selectedStoredValue = "";
});
}
});
$("#producttype").change(function() {
if ($("#producttype").prop('selectedIndex') == "3") {
$('select#socialopt').find('option').each(function() {
$(this).prop('disabled', false);
selectedStoredValue = $("#socialopt option:selected").text();
});
} else {
$('select#socialopt').find('option').each(function() {
$('#socialopt').val('');
$(this).prop('disabled', true);
selectedStoredValue = "";
});
}
});
console.log(selectedStoredValue);
});