Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to refresh a page and also clear form

Status
Not open for further replies.

SSJpn

Technical User
Oct 7, 2002
259
US
I want to have a form where people enter.... for example their name. For the purpose of this example, say i only want to except the form if the name is John.. for all other entries i want the form the be cleared( and the page to be refreshed if necessary). How would i do this?

PS - please assume I have the backend coding already finished to check to see whether the name is John or not.
 
If you already have the coding in place to check for "John" then you just need a button.

To simply clear the page, use
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Reset&quot;>

To actuall refresh the page try:
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Refresh&quot; onClick=&quot;history.go(0)&quot;> Kevin
slanek@ssd.fsi.com

&quot;Life is what happens to you while you're busy making other plans.&quot;
- John Lennon
 
Hmm I see...

but what i am looking for is that the user does not need to push any buttons. I want the page to refresh by itself. Can i include some code that makes the page think the user hit a button? or is there a command or function that refreshes the page without and user input??
 
I do not understand you question completely. How is the page going to work; where it does not need a user's click to submit the page. However, you can try the following javascript to perform this task. This script will be executed at the place that it is inserted into your code. So you will want to watch where you place it into your code.

<SCRIPT language=&quot;javascript&quot;>
document.formname_here.submit();
document.formname_here.reset();
<scriptguage=&quot;javascript&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top