472,780 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

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.frmUser.name = "" ;
document.frmUser.user = "" ;
document.frmUser.contactNumber = "";
document.frmUser.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
Jul 5 '07 #1
16 16472
epots9
1,351 Expert 1GB
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?
Jul 5 '07 #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?
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
Jul 5 '07 #3
kovik
1,044 Expert 1GB
Just like forms have a submit() function, they have a reset() function. You don't have to make your own.

Expand|Select|Wrap|Line Numbers
  1. <input type="submit" value="Submit" />
  2. <input type="reset" value="Reset" />
Jul 5 '07 #4
@ 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
Jul 5 '07 #5
epots9
1,351 Expert 1GB
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
Jul 5 '07 #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
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.location.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
Jul 5 '07 #7
gits
5,390 Expert Mod 4TB
[code]

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

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

document.frmUser.name = "" ;
document.frmUser.user = "" ;
document.frmUser.contactNumber = "";
document.frmUser.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
Jul 6 '07 #8
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?
Jul 6 '07 #9
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.location.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
Jul 6 '07 #10
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:

Expand|Select|Wrap|Line Numbers
  1. function reset_page()
  2. {
  3. document.location.reload("location?type=<%=USER_TYPE%>");
  4. }
  5.  
  6.  
[html]
<INPUT type=button value=Reset onClick = “reset_page()”>
[/html]

Thanks for all help and support.
Sree
Jul 6 '07 #11
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.location.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.location.reload("location?type=<%=USER_TY PE%>");
}

[/js]

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

Thanks for all help and support.
Sree
Jul 6 '07 #12
dafodil
392 256MB
Anytime.... anytime....
Jul 6 '07 #13
gits
5,390 Expert Mod 4TB
... glad you got it working ... and that you find the solution for yourself ;) ... come back when you have more questions ...

kind regards
Jul 6 '07 #14
acoder
16,027 Expert Mod 8TB
Merged the threads.
Jul 6 '07 #15
acoder
16,027 Expert Mod 8TB
[js]
function reset_page()
{
document.location.reload("location?type=<%=USER_TY PE%>");
}

[/js]
Sree, it's good that you got your problem solved. Just one thing about the code tags. [js] won't work. Use [code=javascript] with the ending code tag. Thanks.
Jul 6 '07 #16
Sree, it's good that you got your problem solved. Just one thing about the code tags. [js] won't work. Use [code=javascript] with the ending code tag. Thanks.

Thanks a lot. Yes, sure will rem that the next time.

Cheers
Sree
Jul 6 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) {...
0
by: David Virgil Hobbs | last post by:
What programming codes will enable me to achieve interaction between vb or c# and HTML form values, without a page reload occurring every time a script is run? At least with javascript and vb...
1
by: Simon Wigzell | last post by:
I have a form with several different submit buttons that does different thinkgs depending which button is clicked. (All the submit buttons are named "Submit" and my form uses the asp...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
0
by: drisso | last post by:
I found it convenient in asp.net 1.1 that you could easily define a dataadapter through a wizard and when the page reloads the initialize component would recreate it for you each time. Now that...
1
by: norman29 | last post by:
Hi all! How can i do this: <form method="get" action="test.asp" > <input name="boys" type=radio value="John">John <input name="boys" type=radio value="Lu">Lu <input name="boys"...
3
by: nkoriginal | last post by:
Hello: I tried an script for keep my data form after reload page, but I've some errors. In this momento I runnung my own browser because we've an intranet. And for security reason, our page...
1
by: nkoriginal | last post by:
Hello Again: I've a problem with my forms. I woking with an intranet, and the pages in that intranet, has a reload page, every 10 minutos. So my problems star, when any user stay in my forms...
1
devonknows
by: devonknows | last post by:
hi ive got this at the end of my settings page, and i want it show the fmrSearch form change the check1.value, but everytime i do it, it takes two or three attempts for it to change (having to go...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.