Skip to content Skip to sidebar Skip to footer

Showing Specific Text Output Based On 2 Drop Down Selections

I want to display two text strings depending on a user's selection from two drop down lists. So there are two drop down options: For each month option, I want to have a correspon

Solution 1:

$("#month, #color").change(function () {
    var month = $("#month").val();
    var color = $("#color").val();
    var content = '';
    if (month && color) {
        var monthlabel = $("label[for="+month+"]").text();
        var colorlabel = $("label[for="+color+"]").text();
        content = 'Your animal name is ' + monthlabel + ' ' + colorlabel;
    }
    $("#output").text(content).fadeIn();
});

FIDDLE


Post a Comment for "Showing Specific Text Output Based On 2 Drop Down Selections"