Если вы правильно поняли, вы могли бы попытаться удалить атрибут name
из меню SELECT
, если выбрано значение other
, и назначить атрибут name
вместо ввода text
элемент - когда форма отправляется, элемент в массиве POST с именем country
приходит из текстового поля, а не из меню выбора ...
$('#country').change(function(){
if( this.value == 'Other' ){
$('#country_other').show();
$('#country_other').attr('required', false);
/* remove name from select & add to text field */
$('#country_other').attr('name', $(this).attr('name') );
$(this).removeAttr('name');
} else {
$('#country_other').hide();
$('#country_other').val('');
$('#country_other').attr('required', false);
/* remove name attribute from text field and assign back to select menu */
$(this).attr('name', $('#country_other').attr('name') );
$('#country_other').removeAttr('name');
}
});