Help please (php/javascript related issue)

Discussion in 'General Off-Topic Chat' started by dice, Mar 20, 2011.

Thread Status:
Not open for further replies.
Mar 20, 2011
  1. dice
    OP

    Former Staff dice pansy-ass ex-staff member

    Joined:
    Oct 26, 2002
    Messages:
    9,542
    Location:
    England
    Country:
    United Kingdom
    As part of a uni project I'm building a site that includes the use of forms.

    What I HAVE to do is include a clear button which when clicked upon confirms if the user wishes to remove all entered info from within the form (prior to its submission - i.e. if they make a typo in multiple fields and wish to re-enter from the beginning).

    I know how to do this without the pop-up message, but not with it.

    Any help would be much appreciated.

    Below are snippets of my code:
    CODE*within the body*






    *within the head*


    function msg()
    {
    ÂÂÂÂvar ask = confirm('Clear the form?');
    ÂÂÂÂ
    ÂÂÂÂif (ask)
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂ}
    ÂÂÂÂ
    ÂÂÂÂelse
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂalert('OK, Nothing will be removed.');
    ÂÂÂÂ}
    }


    * edit - I have also tried setting the input type to "reset"
     
  2. tj_cool

    Supervisor tj_cool Stuff

    Joined:
    Jan 7, 2009
    Messages:
    9,942
    Location:
    This planet
    Country:
    Belgium
    Try

    HTML

    ....


    You won't need the JS in the header like this.
     
  3. dice
    OP

    Former Staff dice pansy-ass ex-staff member

    Joined:
    Oct 26, 2002
    Messages:
    9,542
    Location:
    England
    Country:
    United Kingdom
    thank you tj! it works. [​IMG]
     
Thread Status:
Not open for further replies.

Share This Page