Skip to content Skip to sidebar Skip to footer

How To Make The Message Appear Without Typing In The Form

I just want to appear the message after I select the room and time in the drop down buttons. I select all of this, it will appear in the form like this: The code above was inside

Solution 1:

#time_room's 'input' event will fire only on manual input, not when its value is set by javascript/jQuery.

There seems to be no point in attaching an event handler to #time_room as its value will (or should) only ever change in response to #rooms and #time being changed.

You need to cause $.post(...) to be called when either #rooms or #time is changed.

$(document).ready(function() {
    $('#rooms, #time').on('change', function() {
        var time_room_value = $('#rooms').val() + ' ' + $('#time').val();
        $('#time_room').val(time_room_value);
        $.post('check.php', { 'time_room': time_room_value }, function(result) {
            $("#feedback").html(result).show();
        });
    });
    // $("#feedback").load('check.php').hide(); // no point loading a message that will not be seen?
    $("#feedback").hide();
});

Note, I changed input to the more usual change event.

Post a Comment for "How To Make The Message Appear Without Typing In The Form"