Verify Changed Items

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Rivers

    Verify Changed Items

    Hi,

    Is it possible to verify, using js, if ANY item in a form has changed?

    For example: I have a <form> with multiple items (<input>, <select>,
    <textarea>, etc). I need to track if one (or more) of this items has
    changed by a user.

    One option, is to put a onChange event in each one of these fields
    and, if the event occurs, I will update a hidden input to indicate
    that something changed on the form.

    But, the problem is that my form is big, and I was wondering if I
    could check this situation by invoking something like
    if(document.for m[0].changed)...

    Is it possible?

    TIA,

    Bob
  • kaeli

    #2
    Re: Verify Changed Items

    In article <aa669e9b.03080 61322.f1663d6@p osting.google.c om>,
    bobrivers@pobox .com enlightened us with...[color=blue]
    > Hi,
    >
    > Is it possible to verify, using js, if ANY item in a form has changed?
    >[/color]

    Yes.
    [color=blue]
    > For example: I have a <form> with multiple items (<input>, <select>,
    > <textarea>, etc). I need to track if one (or more) of this items has
    > changed by a user.
    >
    > One option, is to put a onChange event in each one of these fields
    > and, if the event occurs, I will update a hidden input to indicate
    > that something changed on the form.
    >
    > But, the problem is that my form is big, and I was wondering if I
    > could check this situation by invoking something like
    > if(document.for m[0].changed)...
    >
    > Is it possible?
    >[/color]

    No, not like that.
    Before the user does anything, have the script loop through the form
    elements and save the values to an array or other structure (I'd use an
    array and make the index be the same as the form element index for easy
    compare later). When the user goes to submit or when you want to check,
    loop again and compare the values.

    That's assuming there is a reason you don't want to just use onChange.
    Using onChange will not catch if a user changes a value then changes it
    back to its original value (thus it wasn't really changed).


    -------------------------------------------------
    ~kaeli~
    The secret of the universe is @*&^^^ NO CARRIER
    The more ridiculous a belief system, the higher
    the probability of its success.


    -------------------------------------------------

    Comment

    • Bob Rivers

      #3
      Re: Verify Changed Items

      bobrivers@pobox .com (Bob Rivers) wrote in message news:<aa669e9b. 0308061322.f166 3d6@posting.goo gle.com>...[color=blue]
      > Hi,
      >
      > Is it possible to verify, using js, if ANY item in a form has changed?
      >
      > For example: I have a <form> with multiple items (<input>, <select>,
      > <textarea>, etc). I need to track if one (or more) of this items has
      > changed by a user.
      >
      > One option, is to put a onChange event in each one of these fields
      > and, if the event occurs, I will update a hidden input to indicate
      > that something changed on the form.
      >
      > But, the problem is that my form is big, and I was wondering if I
      > could check this situation by invoking something like
      > if(document.for m[0].changed)...
      >
      > Is it possible?
      >
      > TIA,
      >
      > Bob[/color]

      Just for the archive collections...

      I received two good sugestions: one from Jim that controls the events
      that have occured in the form.

      And another solution from Kaeli that suggests to store the field
      values into an array, using the onLoad and then when I leave the page,
      compare the values againg with the one stored.

      I decided to use Jim's solution.

      Thanks everybody,

      Bob

      Comment

      Working...