How to catch reset of a form not before, but right after the event?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Smith

    How to catch reset of a form not before, but right after the event?

    Hello. Can anybody read this and come up with the solution? I would
    appreciate any input.

    In my form I have two fields (Field1 is select and Field2 is text input).
    Field1 has "onchange" event which fires a function which hides or displays
    Field2 depending on chosen value of Field1 by means of manipulating style
    "display" property setting it to "none" or "inline".

    Everything works fine, but only problem is reset button. When Field1 is
    reset then onchange for Field1 is not triggered. So, I have a situation when
    Field2 is displayed or hidden when it should not be according to value
    Field1.

    I tried to use "onreset" event to put there the logic of hiding/displaying
    of Field2, but this event seems to trigger BEFORE and not right AFTER reset.
    So, I don't have reset value of Field1 at that moment.

    Thanks
    JS


  • kaeli

    #2
    Re: How to catch reset of a form not before, but right after the event?

    In article <STzTa.45392$PD 3.4483422@nnrp1 .uunet.ca>, some1@microsoft .com
    enlightened us with...[color=blue]
    > Hello. Can anybody read this and come up with the solution? I would
    > appreciate any input.
    >
    > In my form I have two fields (Field1 is select and Field2 is text input).
    > Field1 has "onchange" event which fires a function which hides or displays
    > Field2 depending on chosen value of Field1 by means of manipulating style
    > "display" property setting it to "none" or "inline".
    >
    > Everything works fine, but only problem is reset button. When Field1 is
    > reset then onchange for Field1 is not triggered. So, I have a situation when
    > Field2 is displayed or hidden when it should not be according to value
    > Field1.
    >[/color]

    Call the same function when the user hits reset.

    <input type="reset" onclick="whatev erFunctionToCle arBoxes();">


    -------------------------------------------------
    ~kaeli~
    Black holes were created when God divided by 0.
    Not one shred of evidence supports the notion
    that life is serious.


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

    Comment

    • HikksNotAtHome

      #3
      Re: How to catch reset of a form not before, but right after the event?

      In article <MPG.1988a5b268 ab957798973f@nn tp.lucent.com>, kaeli
      <infinite.possi bilities@NOSPAM att.net> writes:
      [color=blue]
      >Call the same function when the user hits reset.
      >
      ><input type="reset" onclick="whatev erFunctionToCle arBoxes();">[/color]

      Another alternative:

      <input type="button" onclick="...... ..">

      And let the function use .reset() to programatically reset the form.
      Then, you can control what order it gets reset in.

      --
      Randy
      All code posted is dependent upon the viewing browser
      supporting the methods called, and Javascript being enabled.

      Comment

      Working...