Detecting a change on a hidden field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    #1

    Detecting a change on a hidden field

    How do you get a trigger/event to fire on a hidden field. In this case I have a hidden field that is updated via a script. It seems when a field is updated in this manner none of the event triggers like "onChange" "onSelect" "onBlur" will fire.

    Is there some script based way this can occur?

    Currently I add code to every method I use to update a field from script. But I have a number on methods that does this, and I do not wish to go into each of them and add code that the field has been changed. I am looking for some way for the field to detect that something changed.
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by Claus Mygind
    How do you get a trigger/event to fire on a hidden field. In this case I have a hidden field that is updated via a script. It seems when a field is updated in this manner none of the event triggers like "onChange" "onSelect" "onBlur" will fire.

    Is there some script based way this can occur?

    Currently I add code to every method I use to update a field from script. But I have a number on methods that does this, and I do not wish to go into each of them and add code that the field has been changed. I am looking for some way for the field to detect that something changed.
    I think you might be changing the hidden input's value with JavaScript, as its not possible otherwise.

    So just after you change the value of the field, in the next line, execute the code which you want to execute onchange.

    Comment

    • Claus Mygind
      Contributor
      • Mar 2008
      • 571

      #3
      Originally posted by hsriat
      I think you might be changing the hidden input's value with JavaScript, as its not possible otherwise.

      So just after you change the value of the field, in the next line, execute the code which you want to execute onchange.
      You are correct. I am changing value via scripts (note plural). I did not want to have to change every script that updates the value of the field. I wanted the field to detect the change and fire the event, the same as if the user had made the change.

      I have an add/edit/delete screen. On it I have several methods for the user to fill the form elements i.e. they can type in the field, they can use one of my search methods which open sub-windows for lookup purposes where they can select a record which is then backfilled on the calling screen via script. I am now adding ajax communication which goes out to look for the next 30 records which can be used by the user for browsing. So as you see there are a number of ways to fill the field. But only the user input (typing in the field) will trigger the onChange. And of course on my previous search methods I use script to mark the change. I was just hoping for a single point to capture any change that occurred regardless of the method of change.

      Is that possible?

      Comment

      Working...