Skip to content Skip to sidebar Skip to footer

Update Text Input Field Dynamically Using Two Select Menus With Javascript

I am trying to figure out how to dynamically update a text input field when a user changes the option in one or two HTML select menus. I have included my code below showing how it

Solution 1:

as said by JoDev, the select element's object is referenced with $('#tickets') and not just $('tickets'). also, I don't think that there is a value property in jquery for a select element. you can get the value with the val() function.

Created a little fiddle for you here here

$('#tickets').change(function() {
   $('#output').val($(this).val() + " - " + $('#fiftytickets').val());
});
$('#fiftytickets').change(function() {
   $('#output').val($('#tickets').val() + " - " + $(this).val());
});

Post a Comment for "Update Text Input Field Dynamically Using Two Select Menus With Javascript"