Re: Is this a double submit problem?




U¿ytkownik "Conrad Lender" <crlender@xxxxxxxxx> napisa³ w wiadomo¶ci
news:f4ydnRyB3Ol_dKLXnZ2dnUVZ_gRi4p2d@xxxxxxxxxxxxxxxx
On 22/06/09 22:15, Konrad Ciborowski wrote:
(I don't know about other browsers but for me
it has to work under IE 6).

Please don't do this. Applications like yours are the reason why we
still have to fight with outdated user agents like IE6. Make it work
according to the standards, and your clients won't have a problem when
they want to upgrade to a more recent browser.

I have no problem with doing it in such a way so it works under
all browsers but I still don't know how to do this (even in IE6 alone).
I read your first reply (to my first post sent a tad too soon)
but I cannot get to to work.

I changed my button to

<INPUT type=submit name=guzik id=guzik value=Submit>

and added your snippet

var myForm = document.getElementById('testowa'), myFormSubmitted = false;

myForm.onSubmit = function() {
alert("HHH");
if (myFormSubmitted) {
return false;
}
myFormSubmitted = true;
return true;
};

but JS never seems to enter the function() -

alert("HHH")

never gets called.
I feel like I'm missing something blindingly obvious
but I still can't make the damn thing work.

Before I posted to this group I tried a number
of solutions with global variables but to no avail.




The for loop does nothing interesting,
it is there simply to make the execution of the
function last a while (a few seconds - this the key
component of the equation).

There's no sleep() in JavaScript, and using meaningless loops to consume
100% CPU for a while is not a replacement. If you need a delay for some
reason, use setTimeout().

I seemingly didn't make myself clear. In real application
I have a JavaScript function that I need to call
before submitting the form which does a number of
things and takes about 6 seconds to complete.
If the user hits the submit button again in this
time (even though the first thing I do in the
function is to disable the button)
then when the VerySlowJavaScriptFunction() finally
terminates the form is submitted and the page
reloads but IE6 for some unknown reason
reenters the VerySlowJavaScriptFunction() again.

And this, from what I can tell, the heart of the problem.
Normally if one calls a JS function before
submitting a form it takes a franction of a second to return
so the user simply is not able to react that fast -
JS functions normally are quick.

What it takes so long is another matter - it
is a structure I inherited and before I revamp
the whole program to move the stuff from the
VerySlowJavaScriptFunction() to the
server side I want to know what my options are.


See my reply to your first post for suggestions about how to prevent
multiple submits.

for (var z = 1; z < 10000; z++) {
var leftSelect = document.getElementById('select1');
for (i = 0; i < leftSelect.options.length; i++) {
if (leftSelect.options[i].selected) {
leftSelect.options[i].selected = false;
} else {
leftSelect.options[i].selected = true;
}
}
}
for (i = 0; i < leftSelect.options.length; i++) {
leftSelect.options[i].selected = true;
}

Ugh. I'm not going to run this :-)

Why not?
If you did I'd truely appreciate it because you
could see what my problem is.
Becasue from your reply I conclude that
perhaps we are not on the same wavelength.

Best regards,


Konrad Ciborowski
Kraków, Poland


.


Loading