Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Java script reset problem

Java script reset problem

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavajavascriptasp-net
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    immu5
    wrote on last edited by
    #1

    I have one asp.net page (Page1) with llots of controls. After submitting this page, I have another page (Page2) on which there is one link which redirects me again to the same page from which I came from but with prefilled values. On the original page (Page1), there is one link "Clear Fields". Onclick of this link I want to clear all the controls. document.forms[0].reset() --- Not working in this case. Before submitting the form, if I fill up the values and click on "Clear Fields" link, I am able to reset all the controls but once I submit the form and came back to the same page, the above javascript code is not working. Can anyone help me!!

    Y N 2 Replies Last reply
    0
    • I immu5

      I have one asp.net page (Page1) with llots of controls. After submitting this page, I have another page (Page2) on which there is one link which redirects me again to the same page from which I came from but with prefilled values. On the original page (Page1), there is one link "Clear Fields". Onclick of this link I want to clear all the controls. document.forms[0].reset() --- Not working in this case. Before submitting the form, if I fill up the values and click on "Clear Fields" link, I am able to reset all the controls but once I submit the form and came back to the same page, the above javascript code is not working. Can anyone help me!!

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      Well, you would need to set all the control values to their default values. Look Here[^]

      Yusuf May I help you?

      1 Reply Last reply
      0
      • I immu5

        I have one asp.net page (Page1) with llots of controls. After submitting this page, I have another page (Page2) on which there is one link which redirects me again to the same page from which I came from but with prefilled values. On the original page (Page1), there is one link "Clear Fields". Onclick of this link I want to clear all the controls. document.forms[0].reset() --- Not working in this case. Before submitting the form, if I fill up the values and click on "Clear Fields" link, I am able to reset all the controls but once I submit the form and came back to the same page, the above javascript code is not working. Can anyone help me!!

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        First of all it seems an extremely poor design to one a page that simply redirects back to the page you came from, and is most likely causing you more difficulties. Using viewstate, or some other form of persistence, the controls can retain there values between postbacks. You should also be using a cross-browser JavaScript library such as JQuery.


        I know the language. I've read a book. - _Madmatt

        I 1 Reply Last reply
        0
        • N Not Active

          First of all it seems an extremely poor design to one a page that simply redirects back to the page you came from, and is most likely causing you more difficulties. Using viewstate, or some other form of persistence, the controls can retain there values between postbacks. You should also be using a cross-browser JavaScript library such as JQuery.


          I know the language. I've read a book. - _Madmatt

          I Offline
          I Offline
          immu5
          wrote on last edited by
          #4

          Here is my problem... On first page, i have some fields for user input. Based on user input on first page, will display the results on second page. On second page, i have modify button, which takes me to first page. So clicking on reset button on first page doesn't clear off all the fields if i coming from second page. Before submitting the first page, the values are resetting.

          N 1 Reply Last reply
          0
          • I immu5

            Here is my problem... On first page, i have some fields for user input. Based on user input on first page, will display the results on second page. On second page, i have modify button, which takes me to first page. So clicking on reset button on first page doesn't clear off all the fields if i coming from second page. Before submitting the first page, the values are resetting.

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            This functionality can, and should, be accomplished on the same page. Enabling or disabling the controls to put them in edit mode or non-edit mode is the typical implementation and what would be expected by users.


            I know the language. I've read a book. - _Madmatt

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups