I would like to raise an alert when the value is changed. I’ve added this:
<input
…
onchange=‘alert(“here”);’
/>
but it doesn’t work. Anyone know how to make it work please?
Thanks
Not sure if this makes a difference, but you have the input marked readonly, so it should never change (which maybe why your alert isn’t getting invoked)
Thanks. I removed that line and it makes no difference. Actually the fact that it’s marked readonly doesn’t mean it can’t change, only that it can’t be changed in the usual way of typing something into the box. It can still be changed by JS or php.
It can’t be changed with PHP in a way that would trigger the onchange event, it’ll always have to be triggered via Javascript.
Even then, changing the value of an input box programmatically won’t actually trigger the onchange event…I know, weird. Wherever you’re changing the value in your script, add: