1

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?

2
  • 1
    In the future, please don't refer to a select element as a "dropdown menu". They are not the same, as a dropdown menu usually refers to a CSS menu with hover effects. Commented Jan 26, 2011 at 18:02
  • 1
    $('#element_3').bind('change', calcPrice); Commented Jan 26, 2011 at 18:11

3 Answers 3

1
$("#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

http://api.jquery.com/change/

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

@Andrei Korchagin: Working example -- http://jsfiddle.net/Mvwuq/

Just add change to your bind:

$('#element_3').bind('change keydown keyup keypress', calcPrice); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.