0

How do I write a JavaScript code such that when there is an increase in the value of an input type="text", it should do something.

I fetch a count of database table row into the input, so I want it to alert when there is a change/increase in that value. Thanks

Anonymous
  • 49
  • 6
  • Question is far too broad per guidelines in the [help]. Do some research into form control events and using ajax – charlietfl Aug 04 '19 at 16:57
  • A little knowledge of the React.js library might help as well. – Udo E. Aug 04 '19 at 16:59
  • I have an ajax query that takes care of the input value. All I want is a simple JavaScript code that hold that value in a global variable, such that when the value changes, it should alert the new value and store it in the global variable – Anonymous Aug 04 '19 at 17:09

1 Answers1

0

The best way to do it - using sockets.
Logic something like that: on event that modify counter you should "emit" value to frontend. Frontend catch new value and update DOM. Here is example of server side part: Using PHP with Socket.io

Community
  • 1
  • 1