Questions tagged [onchange]

The onChange event gets triggered when the state of an element is changed. Many languages which work with a GUI support some form of a change-event. For example JavaScript and the JavsScript library jQuery (with the .change() function).

The onChange event gets triggered when the selection, the checked state or the contents of an element have changed.

JavaScript

In some cases the onchange event only occurs when the element loses the focus. In the event handler JavaScript code or function get be executed. This can for example be used to validate the data that has been entered by the user by calling a specified JavaScript function.

jQuery

jQuery uses the .change() function which gets called onchange:

<input type="text" name="someinput">

$('input[name="someinput"]').change(function() { });

HTML

HTML supports the inline onchange attribute. Most of the time JavaScript code or a JavaScript function gets executed from the onchange attribute, e.g.:

<input type="text" name="someinput" onchange="dosomething()">

Please not that although this is supported most people will say that it is cleaner to remove all inline JavaScript from the HTML.

3467 questions
351
votes
18 answers

android on Text Change Listener

I have a situation, where there are two fields. field1 and field2. All I want to do is empty field2 when field1 is changed and vice versa. So at the end only one field has content on it. field1 = (EditText)findViewById(R.id.field1); field2 =…
inrob
  • 4,969
  • 11
  • 38
  • 51
330
votes
10 answers

onchange event on input type=range is not triggering in Firefox while dragging

When I played with , Firefox triggers an onchange event only if we drop the slider to a new position where Chrome and others triggers onchange events while the slider is dragged. How can I make it happen on dragging in…
Prasanth K C
  • 7,073
  • 5
  • 39
  • 62
314
votes
9 answers

jQuery - Detect value change on hidden input field

I have a hidden text field whose value gets updated via an AJAX response. When this value changes, I would like to fire an AJAX request. Can anyone advise on how to detect the change? I have…
Ben
  • 6,026
  • 11
  • 51
  • 72
274
votes
5 answers

Counting Chars in EditText Changed Listener

In my project I have an EditText. I want to count the characters in the EditText, and show that number it in a TextView. I have written the following code and it works fine. However, my problem is when I click Backspace it counts up, but I need to…
Hesam
  • 52,260
  • 74
  • 224
  • 365
262
votes
17 answers

How to pass parameters on onChange of html select

I am a novice at JavaScript and jQuery. I want to show one combobox-A, which is an HTML with jQuery?
?
omg
  • 136,412
  • 142
  • 288
  • 348
203
votes
8 answers

React Checkbox not sending onChange

TLDR: Use defaultChecked instead of checked, working jsbin. Trying to setup a simple checkbox that will cross out its label text when it is checked. For some reason handleChange is not getting fired when I use the component. Can anyone explain…
jdarling
  • 2,438
  • 2
  • 14
  • 10
143
votes
5 answers

Trigger change() event when setting when using @bind also?

I need to be able to run a function after a selection in made in a