1

I have a dropdown and a textbox.

I'm passing the dropdown value to a textbox.

And the dropdown I've created using jquery.dropdown. And so I can't directly write a function like $('.dropdown').change(function() {}).

Now I wanted to write a function on textbox change.

I tried few functions. But nothing helped me out.

It only works if I manually type or press enter while focused on the textbox.

Fiddle.

2 Answers 2

3

Programatically changing a value does not trigger events, only user interaction does that.
You'd have to trigger the event yourself

$("input[name='textbox']").val(value).trigger('change');

FIDDLE

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

1 Comment

Great!! Thanks a lot. That helped me out. So the values generated or passed progrmatically does not trigger any events. Thanks again. +1 :)
0

You can just use change function to trigger the event:

$('.dropdown').change(function() {

    $("input[name='textbox']").val(this.value).change()
})

Here Is your updated script

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.