473,379 Members | 1,235 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 16597
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.