$(function() {
    $(document).on('change', '#custom-field-type', function() {
        if ($(this).val() == 'selection') {
            $("#selection-field-container").fadeIn()
        } else {
            $("#selection-field-container").fadeOut();
        }
    })

    $(document).on('click', '#selection-field-container a', function() {
        var input = $("<input style='margin: 10px 0' type='text' class='form-control' name='val[options][]' placeholder='Enter option'/> ");

        input.insertBefore($(this));
        return false;
    });

    $(document).on('change', '.newsletter-to', function() {
        var v = $(this).val();

        if (v == 'selected') {
            $('.selected-members').show();
        } else {
            $('.selected-members').hide();
        }
    })
});