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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resetting form values

Status
Not open for further replies.

pmachin

Programmer
Feb 20, 2004
5
US
Hi,
I'm trying to reset the values of a form on submission. I tried the following exactly
My document's name is abc.cgi the form's name is myForm
supposedly this is the standard format
<FORM name="myForm" onSubmit="document.myForm.content.value=''">
so I tried the above exactly, as well as:
<FORM name="myForm" onSubmit="abc.cgi.myForm.content.value=''">

but it doesn't work.
What do I need to change to make this work.
If you know another way to reset a form without the button please tell me.

Thanks in advance.
 

> I'm trying to reset the values of a form on submission

Then there's no point in even submitting the form, or indeed, having a form in the first place.

If the values are reset before you submit then they will always be known, as they will be the default ones.

Dan
 
ok? I thought this took effect when the page is reloaded. Thats essentially what Im trying to do, have the default values of the form once the page its in is reloaded again.
 
The problem is this:<br>
I have a script a.cgi in which I have a form that submits the name of a text field to another script, b.cgi. Then b.cgi uses this name (does something) and returns it back to a.cgi (via a hidden field) to display this name in the some html generated by a.cgi after it returns from b.cgi.
(This is for a forum. The main page (a.cgi) contains a request for new thread in the form of a text box. Once a name for a new thread is entered, you are taken to the writting page (b.cgi). Then you're redirected back to a.cgi to display the name of the posting as a n html link to the actual post (a text page generated in the previous page) )
The problem is that a single post has been posted and I'm back in a.cgi looking at the hyperlink, if I press reload, another identical last thread link appears. This is because the a.cgi form that first forwarded the name is retaining its last entered value and creating a form everytime a.cgi is refreshed. (I dont mind that the form that creates a new thread is run everytime the page is refreshed since I have a check that doesn't write the thread if the name entered is less than four characters in length such that when a new form tries to be generated with a blank name it is ignored)
<br>
I actually got the forum going by making it only display the forum link in a.cgi if the last page was b.cgi (the page in which the form is written) and the form name is not in the log file that contains all of the thread names. However, I shouldn't need the first check. How can I get a fresh form everytime the page is refreshed without using these checks?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top