Reset the form to Null or Reload the page usign reset even after a submit

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreemati
    New Member
    • Jun 2007
    • 42

    Reset the form to Null or Reload the page usign reset even after a submit

    Hi everyone,

    This is the scenario:

    I have two button - Submit and Reset

    Submit is used for validation and after validation is passed it passes it to another form to enter into database.

    Bascially the reset works fine if I use it before using the submit button in the form. For instance,if on submit there is some error as the values have not passed a validation. There is a error pop up message shown and the values are retained in the field and Now if I use reset , all the values of the field do not go back to null.

    I am new with form validation. I checked online and it said that reset will not clear if we have used submit and we need to use javascript to do it.

    So I made reset into a button which onclick event calls the reset() function and clears the form but I am sure that the code is not right as it is not working, I tired putting a alert message in my fucntion to reassue that the function is being called but I think it is not.

    Posting my code

    [Code]

    <INPUT id=reset1 name=reset1 type =button value=Reset onClick="reset( )">

    <Script>
    function reset()
    {
    alert ("all values shall be cleared now");

    document.frmUse r.name = "" ;
    document.frmUse r.user = "" ;
    document.frmUse r.contactNumber = "";
    document.frmUse r.email = "" ;

    }
    </Script>

    I am not sure if its the best way to do it.

    I want the whole form to refresh/ reload everytime reset is clicked and all the fields to have no values.

    Thanks for the help in advance.

    Sree
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    i might have heard about this, or maybe its somethings else but..

    what language are u using to write the webpage? HTML, PHP, ASP.NET?

    Comment

    • sreemati
      New Member
      • Jun 2007
      • 42

      #3
      Originally posted by epots9
      i might have heard about this, or maybe its somethings else but..

      what language are u using to write the webpage? HTML, PHP, ASP.NET?
      I am using ASP page. Its just I want to set all the field values to null when we click reset. Javascript tutorials mention usign reset value but my IE browser says, does not support this object. So I may have to set all the values back to null??? I am nto sure, actually confused :D

      Comment

      • kovik
        Recognized Expert Top Contributor
        • Jun 2007
        • 1044

        #4
        Just like forms have a submit() function, they have a reset() function. You don't have to make your own.

        [code=html]<input type="submit" value="Submit" />
        <input type="reset" value="Reset" />[/code]

        Comment

        • sreemati
          New Member
          • Jun 2007
          • 42

          #5
          @ volectrcity

          We have a reset but if the form is called back after failure in validation i.e. once a submit event has happened, the reset button does not clear the form rather, it sets it with the values that were entered before.

          Thats why I have to do it with javascript

          Comment

          • epots9
            Recognized Expert Top Contributor
            • May 2007
            • 1352

            #6
            if your using visual studio for your ASP page, right click the reset button and go to properties. then in there there should be an option for performsubmit, set that to false, and another option to use validator controls set that to false as well

            good luck

            Comment

            • sreemati
              New Member
              • Jun 2007
              • 42

              #7
              Originally posted by epots9
              if your using visual studio for your ASP page, right click the reset button and go to properties. then in there there should be an option for performsubmit, set that to false, and another option to use validator controls set that to false as well

              good luck
              Thanks epots and velo.

              I have solved how to set all the values to null but I think I would rather want to reload/ refersh the whole page but there is a hidden type whoes values MUSt be taken from the comign form and I am stuck as to how to pass this value along with reload event in javascript.

              Can anyone help?

              My code is:

              [js]

              function reset_page()

              {
              document.locati on.reload();
              }

              I am getting error saying: The page can not be refreshed without resending the information. click retry to sent the information again, or click Cancel to return to the page that you were trying to view.

              Can I anyone say how can I reload/refresh my page by passing the hidden values.

              Thanks for your efforts.
              Sree

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                Originally posted by sreemati
                [Code]

                <INPUT id=reset1 name=reset1 type =button value=Reset onClick="reset( )">

                <Script>
                function reset()
                {
                alert ("all values shall be cleared now");

                document.frmUse r.name = "" ;
                document.frmUse r.user = "" ;
                document.frmUse r.contactNumber = "";
                document.frmUse r.email = "" ;

                }
                </Script>
                hi ...

                you have to set the value-property so add .value to the lines ... when you want to set a value of an input-field

                kind regards

                Comment

                • sreemati
                  New Member
                  • Jun 2007
                  • 42

                  #9
                  Originally posted by gits
                  hi ...

                  you have to set the value-property so add .value to the lines ... when you want to set a value of an input-field

                  kind regards
                  Thanks gits,

                  Can you help with reloading a page with parameters passed as being passed by the previous page?

                  Comment

                  • sreemati
                    New Member
                    • Jun 2007
                    • 42

                    #10
                    Reload a page but need to pass specific parameters as well while loading the page

                    I would be of great help if someone can tell mehow to reload/ refersh the page I am in currently but I need to be able to pass a hidden parameter whoes values MUST be taken as if coming from the next page and I am stuck as to how to pass this value along with reload event in javascript.

                    Can anyone help?

                    My code is:

                    [js]

                    function reset_page()

                    {
                    document.locati on.reload();
                    }

                    I am getting error saying: The page can not be refreshed without resending the information. click retry to sent the information again, or click Cancel to return to the page that you were trying to view.

                    Can I anyone say how can I reload/refresh my page by passing the hidden values.

                    Thanks in advance.
                    Sree

                    Comment

                    • sreemati
                      New Member
                      • Jun 2007
                      • 42

                      #11
                      Originally posted by sreemati
                      Thanks gits,

                      Can you help with reloading a page with parameters passed as being passed by the previous page?
                      Hi Solved my problem.

                      I figured out. My solution code is:

                      [code=javascript]
                      function reset_page()
                      {
                      document.locati on.reload("loca tion?type=<%=US ER_TYPE%>");
                      }

                      [/code]

                      [html]
                      <INPUT type=button value=Reset onClick = “reset_page()”>
                      [/html]

                      Thanks for all help and support.
                      Sree
                      Last edited by acoder; Jul 6 '07, 09:02 AM. Reason: code in proper tags

                      Comment

                      • sreemati
                        New Member
                        • Jun 2007
                        • 42

                        #12
                        Originally posted by sreemati
                        I would be of great help if someone can tell mehow to reload/ refersh the page I am in currently but I need to be able to pass a hidden parameter whoes values MUST be taken as if coming from the next page and I am stuck as to how to pass this value along with reload event in javascript.

                        Can anyone help?

                        My code is:

                        [js]

                        function reset_page()

                        {
                        document.locati on.reload();
                        }

                        I am getting error saying: The page can not be refreshed without resending the information. click retry to sent the information again, or click Cancel to return to the page that you were trying to view.

                        Can I anyone say how can I reload/refresh my page by passing the hidden values.

                        Thanks in advance.
                        Sree
                        Hi Solved my problem.

                        I figured out. My solution code is:

                        [js]
                        function reset_page()
                        {
                        document.locati on.reload("loca tion?type=<%=US ER_TYPE%>");
                        }

                        [/js]

                        [html]
                        <INPUT type=button value=Reset onClick = “reset_page()”>
                        [/html]

                        Thanks for all help and support.
                        Sree

                        Comment

                        • dafodil
                          Contributor
                          • Jul 2007
                          • 389

                          #13
                          Anytime.... anytime....

                          Comment

                          • gits
                            Recognized Expert Moderator Expert
                            • May 2007
                            • 5388

                            #14
                            ... glad you got it working ... and that you find the solution for yourself ;) ... come back when you have more questions ...

                            kind regards

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #15
                              Merged the threads.

                              Comment

                              Working...