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.
  1. dice
    OP

    dice pansy-ass ex-staff member

    Former Staff
    4
    Oct 26, 2002
    England
    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

    tj_cool Site dev

    Supervisor
    8
    Jan 7, 2009
    Belgium
    This planet
    Try

    HTML

    ....


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

    dice pansy-ass ex-staff member

    Former Staff
    4
    Oct 26, 2002
    England
    thank you tj! it works. [​IMG]
     
Loading...
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice