From: MG on

"Evertjan." <exjxw.hannivoort(a)interxnl.net> wrote in message
news:Xns9D9DECD3DB100eejj99(a)194.109.133.242...
> MG wrote on 20 jun 2010 in comp.lang.javascript:
>
>> I want the form to be submitted. Then, after a delay, the form is to be
>> reset.
>>
>
> That can only be done, if you submit the form to another window,
> otherwise there is NO form of the old page to be reset,
> because that page is gone and exchanged for a new version
> with a new form.
>
> Try:
>
> <form
> onsubmit = "setTimeout('resetMe()',10000);";
> target = 'anotherWindow';


Thanks, this has helped me.

I am still learning javascript. I found a php code on the internet I want to
use to return the form as email. After a few test I now see what is
happening.

(I start on php next month)

MG


From: Thomas 'PointedEars' Lahn on
Gregor Kofler wrote:

> MG meinte:
>> On this page:
>> http://www.blighty.co.za/resetform/
>> I am testing a script to reset a form after it has been submitted.
>>
>> I have this line:
>> setTimeout('mf.reset()',10000);
>
> mf.reset() is executed immediately and the result becomes the argument
> for the setTimeout method.

No, it is not; notice the string literal? What you are describing would
happen with

setTimeout(mf.reset(), 10000);

> window.setTimeout(mf.reset, 10000);
>
> is what you want.

No, since the calling object would be the global or `window' object then; if
this had a chance to work in the first place, a function expression or an
equivalent Function instance reference would be needed for the first
argument:

window.setTimeout(function () { mf.reset(); }, …);

But the problem here is trying to access the form object (approximately 10
seconds) after it has been deconstructed, since the response to the POST
request is displayed in the same window (the `submit' event is not being
cancelled). It might work if either the `submit' event was cancelled or
clearForm(document.forms[0]) was called in the `onload' attribute, but that
would be a Bad Thing.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
From: Garrett Smith on
On 2010-06-21 03:49 AM, Thomas 'PointedEars' Lahn wrote:
> Gregor Kofler wrote:
>
>> MG meinte:

[...]

> window.setTimeout(function () { mf.reset(); }, …);
>
> But the problem here is trying to access the form object (approximately 10
> seconds) after it has been deconstructed, since the response to the POST
> request is displayed in the same window (the `submit' event is not being
> cancelled). It might work if either the `submit' event was cancelled or
> clearForm(document.forms[0]) was called in the `onload' attribute, but that
> would be a Bad Thing.
>

A doing something onload is different than doing something after a form
submission. Onload affects any request type (GET as well as POST).

And yes, the form submission to the same window was preventing that
setTimeout to run, but the OP seems to have figured that out by now.

Garrett