[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Stopping Multi-submits ?

Mel Smith

9/23/2014 2:59:00 PM

Hi:

Situation:

To forestall a user multi-clicking on a submit button, I use JS code
similar to the following:

getobj("mybuttonid").disabled=true ;
getobj("myloginid").submit() ;

(where the getobj() function is simply my short way of using
document.getElementById() )

Result:
If my server response is very slow, my user hitting the submit button
repeatedly will *not* result in successive submits because the submit button
is now disabled.

Problem:

In IE11 (at least), after the new page arrives, if the user decides to
use the 'back arrow' to re-load the previous page, then that submit button
is *still* disabled, when I wish it to be enabled and ready for another
submit

Question:

How do I restrain multiple submits, *but* allow submits again after a
new page has arrived, and then the user 'arrows' back to the previous page
(or pages).

(btw, I tried putting the re-enabling code in the onload event, but I
guess that the onload code doesn't get activated if the user simply uses his
back-arrow to get his previous page ?? )

Thanks.

-Mel Smith



7 Answers

Anim8rFSK

4/20/2014 4:29:00 PM

0

In article <lj0op7$4g7$1@dont-email.me>,
Ubiquitous <weberm@polaris.net> wrote:

> anim8rfsk@cox.net wrote:
> > Ubiquitous <weberm@polaris.net> wrote:
>
> >> I watched:
> >>
> >> LOVE BOAT:
> >> It's Julie's high school reunion TV movie!
> >> This ep starts with the crew grousing to Captain Stubing about Julie
> >> micromanaging everyone because she wants everything to be perfect for
> >> the Haley High School reunion. Hmm, I need to contact my high school
> >> reunion comittee about doing this!
> >
> >A couple of her classmates are remotely her age, but ... Gilligan? He's
> >more than 20 years older than her! So is Christopher George, despite
> >being Immortal, and her BFF, Kim Darby, is 10 years older.
>
> Don't forget at least two fairly-young teachers were invited as well.

Yeah, age is a problem with the teachers, too. Raymond Burr is only 14
years older than Christopher George, and Charlie's maid is 12 years
*younger*! Plus, Burr should be worried about retirement, and George's
acting career would be pretty much over as well, not 'on his way to
becoming a fine actor'
>
> >> ? "Disco Baby". Two of Julie's classmates are a famous pair of
> >> unmarried disco dancers who are on the outs..
> >
> >This was all over the place. First they weren't a couple personally,
> >just professionally, then he was pretty obviously gay, then he wants
> >Julie, then the partner is pregnant ...
>
> Yeah, that confused me as well. When the guy was oggling the guy in
> speedos, I wondered where they were going with that.

He makes the freaking POINT to Julie, in front of Tabitha, that they
AREN'T a couple, but later they're talking about calling off the
engagement. WTF?
>
> >> The woman barely sets foot on board whne she gets cramps.
> >> Uh oh, we know what THAT means!
> >
> >Yeah, Clint Black's wife spends the cruise grabbing her tummy and
> >barfing...
> >
> >> Julie naturally, is interested in him and flirts incesantly with the
> >> man despite Stubing's long-established "don't date the guests"
> >> policy.
> >
> >Which doesn't apply to Doc. :D
> >
> >> Later, on the Lido deck, the pair lead some bizare disco dance
> >> lessons while the camera tilts and pans back and forth, giving the
> >> impression they're drunken or stoned (so THAT'S where that clip in
> >> the ad for this show on MTtv came!). Sherie begs Julie to back off,
> >> but the guys convince Julie to ignore her (and the Captain's orders
> >> since this show began).
> >
> >So, the morning of the big dance, Julie shows her gay Disco queen the
> >ballroom (for the first time) and asks if he can do the big dance there;
> >he says fine, but it needs lots of speakers along every wall, Julie
> >agrees to put them in place.
> >
> >And again - wait, what? Where have they been dancing up 'til now? What
> >have they been doing with the ballroom up 'til now? What if the guy had
> >said 'that won't do'? Where did Julie get a ton of extra speakers to
> >rig up, and who did the work?
>
> Yeah, and don't they usually plan these things far in advance?
> It reminded me of the impromptu cowboy costume party they threw together
> in the first season.

Yeah, and on the Halloween cruises they apparently have a huge costume
shop for passengers to peruse. But why would they have a storage room
full of speakers!?
>
> >> At the farewall disco, the couple reconnect in a dimly lit disco
> >> dance sequence when wife faints. Yeah, just as I suspected; she's
> >> pregnant! Upon hearing the news, Julie backs off and lets them
> >> reconcile.
> >
> >Not doing the pregnant lady any favors.
> >
> >> ? "Alas, Poor Dwyer". Raymond Burr plays Steve Newport, a bitter
> >
> >hee hee
> >
> >> drunkard musical theatre teacher at Julie's school. After finding him
> >> drunk in a deck chair wearing a life preserver, the captain tells
> >> Isaac to stop serving him. Are they allowed to do that and is Isaac
> >> the only bartender on this ship?
> >
> >Yeah, that's a problem - there has to be more than one place to score
> >booze.
>
> Apparently, Newport was too drunk to think of that.

Of course, we've even seen Isaac bring room service ...
>
> >> Captain Stubing takes Newport to a dry bar for lunch but leaves in
> >> a huff after overhearing Gilligan and another student talking poorly
> >> about him but conveniently before they agree he was their best
> >> teacher. When they're ready to leave port, Newport is nowhere to be
> >> found but before they are forced to leave without him, he is returned
> >> by some Mexican cops and he gives Captain Stubing a "Happy Birthday,
> >> General!" cake. Stubing forces him to drink coffee the next
> >> morning, then confesses he was an alcoholic too and almost ran over a
> >> child on way to work one day and never drank since. Hmm, I am sure
> >> we've seen him drink adult beverages before. At the farewell disco,
> >> Newport gets a class award for being such a great teacher and voes to
> >> remain sober.
> >
> >And yet when he came aboard he was so desperate to get to his cabin and
> >start drinking he turned down an invite to the bridge ... why did he
> >come to the reunion anyway?
>
> I thought he was invited to the reunion.

Sure, but if you can't go more than 20 minutes without a drink, what are
you doing going on a cruise with your students where you'll be with them
24/7? And, come to think of it, where DID he go as they were setting
sail - did he go get room service booze? He doesn't seem to have a
suitcase full of liquor, which would at least make sense.

> I also assumed Stubing would admit that he lied to Newport about almost
> running over that child on the way to work.

I don't think so. We've been told that Stubing's a drunk in other eps.
>
> >> ? "After the War". A man and his wife dread meeting a friend who
> >> became a cripple in Vietnam while they fled to Canada and became
> >> entrepenuers.
> >
> >And somehow the lying coward didn't know his BFF was in a wheelchair.
> >Plus, why isn't he in prison? Ah, the government made him do 2 years of
> >'alternate service' sweeping floors in Miami. That'll teach him!
>
> Hadn't President Ford pardoned all the draft dodgers at that point?

yeah, the timeline works out. Ford's amnesty program made you do that
'alternative service' bit which this guy did, and then lying douchebag
Carter, second worst President I can think of, just pardoned anybody
that asked for it, pissing off everybody on both sides. About half of
the weasely cowards stayed in Canada, polluting their bloodlines with
doucheblood, which goes a long way to explaining Clodreamer. Remember
when the deranged Mayor of New York, John Lindsay, wanted the cowards
that ran to Canada pardoned, but the people that stayed in the USA and
went to prison, left in prison to rot?
>
> >> The husband whines incesantly about what happened to them. They
> >> eventually meet their crippled vet classmate but don't have the
> >> courage to tell him what they did.Later, the couple come across their
> >> wheelchair-bound friend swapping war stories with classmates and the
> >> crew and he makes up some story about having a desk job. Since when
> >> were the crew in 'Nam? Later, while whining to his wife AGAIN, he
> >> lets it slip that his reasons for going to Canada weren't as
> >> idealistic as hers.
> >
> >He does admit to his ugly worthless GF that he had no moral convictions
> >about the war at all, that he's just a rat bastard coward and followed
> >the nasty bitch to get laid.
> >
> >Why did SHE go to Canada again?
>
> I don't remember, but I think she went with him on general principles,
> since I don't think women were ever drafted.

Except from what they said, HE went with HER.
>
> >> At the farewell disco, he confesses the truth his friend, but he
> >> already knew b/c his mother told him and wanted him to say it himself.
> >> blah blah blah. As they disembark, the couple vow to hire as many
> >> disabled vets as they can. Damn, I didn't know they did Vietnam
> >> stories before 1980!
> >
> >The coward who fled to Canada to get out of Viet Nam lied to his war
> >hero buddy in the wheel chair about what a sniveling creep he is to the
> >very end, and a throwaway line at the end had the Mod Squad guy in the
> >wheelchair saying 'oh, yeah, the VA can fix this, that's what the VA is
> >for' - surprise happy ending!
>
> I hated the ending to this story, plus Vietnam stories are so trite and
> cliche, although they weren't at the time this originally aired.

+1

> >> ? "Ticket to Ride". A female classmate of Julie's received her tickets
> >> to the cruise from a secret admirer, along with a sorta creepy note
> >> about "holding his breath until he dies". She meets a nerdy classmate
> >
> >That was her ex BF that she dropped for being too boring.

Yeah, right before he shows up with the flowers, Julie asks where Jim
is, and she says she dropped him for being too boring and predictable
(Julie says they were practically engaged) and her whore friend says
she's anxious to put out for whoever spent a lot of money on her, and
then when he shows, she says JIM! I'm assuming he's the same Jim.
>
> I must have missed that part.
>
> >> who barely scraped enough money to get a ticket and then totally
> >> ignores him when he tries to give her flowers because she's excited
> >> to find out who gave her the tickets. Gee, I wonder who it is! To
> >> make a long story short (too late!), she screws around with several
> >> guys, including Gilligan, she thinks gave her the tickets, only to
> >> dump them as soon as she learns they're not the one.
> >
> >Which makes her a whore.
>
> At least.

At best. :D
>
> >> At the farewell disco, she realizes she wasted her time looking for
> >> her secret admirer and screwing guys looking for him. Julie tell her
> >> to just enjoy herself and dances the night away. When she disembarks
> >> at the end of the cruise, she discovers what we knew all along. The
> >> nerd who couldn't attend did it.
> >
> >? "ITSY BITSY".
> >> At the begining of the cruise, the guys are oggling a picture of a
> >> phys ed teacher in Julie's yearbook and acting like pigs. Since Doc
> >> "popped his thermometer" after seeing her photo, he asked Julie to
> >> set him up on a date, but she turns out to be Charlie Bananas' maid.
> >> Lots of fat jokes were made, which is odd b/c she's not nearly as fat
> >> as she is now and she wasn't roundish at all. After an initial
> >> hesitation, Doctor Bricker and her get along well, but during a dance,
> >> Goofer interuptted them about an emergency and she takes it wrong.
> >> After tending to Newport, he makes up with her and Goofer and Isaac
> >> apologize for making fat jokes. At the farewell disco. Doc and her
> >> vow to meet in Gay Bay and stop at all the restaurants along the
> >> cable car's route.
> >
> >Yeah, she's certainly overweight, but she's hardly horrible. Plus, Doc
> >didn't ask her to stay in his cabin; he's committed to one date. So
> >what? It's not like they don't have dinner with the guests anyway.
>
> Fer sure.

I'm still ... what were they doing here? Is Doc suddenly The Fonz,
who's reputation can't withstand being seen in public with a fat chick?
If he doesn't want to be alone with her, have Julie stick 'em at the
Captain's Table.

--
Wait - are you saying that ClodReamer was wrong, or lying?

Cezary Tomczyk

9/23/2014 6:22:00 PM

0

On 2014-09-23 16:58, Mel Smith wrote:
[...]
> Problem:
>
> In IE11 (at least), after the new page arrives, if the user decides to
> use the 'back arrow' to re-load the previous page, then that submit button
> is *still* disabled, when I wish it to be enabled and ready for another
> submit
>
> Question:
>
> How do I restrain multiple submits, *but* allow submits again after a
> new page has arrived, and then the user 'arrows' back to the previous page
> (or pages).
[...]

Maybe do not disable the button, but instead of that when user clicks on
the button set some state, e.g.:

var submitState = false;

to "true" and when the user clicks on button again just check that state
and do the right action, e.g. if the state == true then show the message
for the user that his "request is still in progress".

--
Cezary Tomczyk
http://www.ct...

Evertjan.

9/23/2014 6:32:00 PM

0

"Mel Smith" <syntel@cox.net> wrote on 23 sep 2014 in comp.lang.javascript:

> Hi:
>
> Situation:
>
> To forestall a user multi-clicking on a submit button, I use JS code
> similar to the following:
>
> getobj("mybuttonid").disabled=true ;
> getobj("myloginid").submit() ;
>
> (where the getobj() function is simply my short way of using
> document.getElementById() )
>
> Result:
> If my server response is very slow, my user hitting the submit
> button
> repeatedly will *not* result in successive submits because the submit
> button is now disabled.
>
> Problem:
>
> In IE11 (at least), after the new page arrives, if the user decides
> to
> use the 'back arrow' to re-load the previous page, then that submit
> button is *still* disabled, when I wish it to be enabled and ready for
> another submit
>
> Question:
>
> How do I restrain multiple submits, *but* allow submits again after
> a
> new page has arrived, and then the user 'arrows' back to the previous
> page (or pages).
>
> (btw, I tried putting the re-enabling code in the onload event, but
> I
> guess that the onload code doesn't get activated if the user simply uses
> his back-arrow to get his previous page ?? )

If you leave the page by form-submission,
clientside javascript cannot help you on this page.

Use
<form onsubmit='return mySubmit(this)' ....

and return false to prohibit a second submit onpage.

Alternatively you can return false all the time
and use myForm.submit() where needed.

To prevent submission on another page,
or on a reload of he same page,
use serverside code.

To prevent the effects of a resubmission after backspacing,
[which you were not planning to do, methinks]
you would have to block the results serverside.

=====================

If you want to stay on the page after submission
use a <form target='...'
and perhaps let that target be an [hidden?] iframe on page.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Mel Smith

9/23/2014 10:27:00 PM

0

Cezary & Evertjan:

Thanks you both for your responses and suggestions.

I'll study them carefully tomorrow --- after golf tomorrow afternoon :))

-Mel


Evertjan.

9/23/2014 10:54:00 PM

0

"Mel Smith" <syntel@cox.net> wrote on 24 sep 2014 in comp.lang.javascript:

> Cezary & Evertjan:
>
> Thanks you both for your responses and suggestions.
>
> I'll study them carefully tomorrow --- after golf tomorrow afternoon
> :))

Mel,

I don't know what "tomorrow afternoon" exactly means,
not knowing where you live on this planet.

Golf I have heard of,
that being a game the Scots stole from the Frisian game of "kolf",
and changing that to the more rough highland environment and the kilt
culture.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Thomas 'PointedEars' Lahn

9/24/2014 12:51:00 AM

0

Cezary Tomczyk wrote:

> On 2014-09-23 16:58, Mel Smith wrote:
> [...]
>> Problem:
>>
>> In IE11 (at least), after the new page arrives, if the user decides
>> to use the 'back arrow' to re-load the previous page, then that
>> submit button is *still* disabled, when I wish it to be enabled and
>> ready for another submit
>>
>> Question:
>>
>> How do I restrain multiple submits, *but* allow submits again after
>> a new page has arrived, and then the user 'arrows' back to the
>> previous page (or pages).
> [...]
>
> Maybe do not disable the button, but instead of that when user clicks on
> the button set some state, e.g.:
>
> var submitState = false;
>
> to "true" and when the user clicks on button again just check that state
> and do the right action, e.g. if the state == true then show the message
> for the user that his "request is still in progress".

However, there is no guarantee that, using the Back feature, the pre-
existing environment will not be sufficiently restored. A sufficiently
reliable client-side possibility are cookies or Local/Session Storage
instead; IOW, anything that is *not* tied to the document or view. HTML5
Push State and equivalents come to mind as well even though they are tied to
the view.

Eventually, this can only be solved reliably server-side, by generating
forms that are not cached (although this could be ignored by the UA as
well), and submit tokens that are generated once, stored in a server-side
session, and expire on successful form submission (anything else could
result in accidental submission if the Forward feature is used
subsequently). This is also the recommended usability and security measure,
given that client-side script code need not be executed.

It is possible to use XHR to improve the user experience, though: the
submission of forms whose token has expired can be cancelled in advance.
The negligible extra cost of this measure can result in a significant
reduction of server load, depending on how much data is being sent when the
submission is successful.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Mel Smith

9/24/2014 2:25:00 PM

0

Evertjan said:

> Mel,
>
> I don't know what "tomorrow afternoon" exactly means,
> not knowing where you live on this planet.
>

Western Canada ! and (during the winter) south-western United States)

> Golf I have heard of,
> that being a game the Scots stole from the Frisian game of "kolf",
> and changing that to the more rough highland environment and the kilt
> culture.

No kilts today -- its only 12C outside as I'm about to leave

-Mel