Reputation: 8882
I used to have a text input at #element_3, where you may type in a number, and a function is run on that number, and the results are outputted dynamically to parts of the page.
I've changed that text input into a dropdown menu, but I don't know what to change in my JS code so that it works. I hope I've explained enough.
Here's my code - http://slexy.org/view/s2cwHc5do2
Bold It seems my problem lies in this line:
$('#element_3').bind('keydown keyup keypress', calcPrice);
It would run the function when something was typed in, hence the keydown keyup keypress. But how do I make it work if there is no typing, but just a select element?
Upvotes: 1
Views: 975
Reputation: 1265
$("#element_3").change(function() { whetever you want in the function });
check out the jquery docs on change, they use the .change() function when a select has a value changed
Upvotes: 1
Reputation: 10371
@Andrei Korchagin: Working example -- http://jsfiddle.net/Mvwuq/
Just add change
to your bind
:
$('#element_3').bind('change keydown keyup keypress', calcPrice);
Upvotes: 0
Reputation: 10598
try this $('#element_3').bind('change', calcPrice);
although hard to say if your calcPrice
function has been re-factored to handle selection rather than input
Upvotes: 1