$(document).ready(function() { var $select = $
Aug 2, 2015
$(document).ready(function() {
var $select = $('#select'),
$custom = $('#custom'),
$customValue = 'Другое',
$name = $('#select').val();
$select.on('change', function() {
if ($name == $customValue) {
$('#custom').show();
}
else {
$('#custom').hide();
}
});
$('#form').on('submit', function() {
if ( ($select.val() == $customValue) && ($custom.val() != '') ) {
$select.val() = $custom.val();
}
else{
$select.val() = $name;
}
});
});