Disabling button onclick in IE

Disabling button onclick in IE

am 01.12.2009 22:06:14 von Skip Evans

Hey all,

You probably remember me asking about disabling a submit
button when it is clicked to prevent double clicks submitting
a form for CC processing.

I put the following code into the submit button and it works
fine on FireFox, but... hold your breath... not on IE.

The button gets disabled but the form just sits there, not
submitting. At first I just had

onclick="this.disabled=true;"

and that worked in FF also, but not in IE. Then I added the

document.ticket_form.submit();

But even that doesn't work with IE.

Below is the whole snippet for the button.

id="submit_tickets" onclick="this.disabled=true;
document.ticket_form.submit();">

Any suggestions would be greatly appreciated.

Thanks,
Skip

--
====================================
Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Disabling button onclick in IE

am 01.12.2009 22:16:07 von Ashley Sheridan

--=-lyNmojjTryW47jUDm4Hq
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Tue, 2009-12-01 at 15:06 -0600, Skip Evans wrote:

> Hey all,
>
> You probably remember me asking about disabling a submit
> button when it is clicked to prevent double clicks submitting
> a form for CC processing.
>
> I put the following code into the submit button and it works
> fine on FireFox, but... hold your breath... not on IE.
>
> The button gets disabled but the form just sits there, not
> submitting. At first I just had
>
> onclick="this.disabled=true;"
>
> and that worked in FF also, but not in IE. Then I added the
>
> document.ticket_form.submit();
>
> But even that doesn't work with IE.
>
> Below is the whole snippet for the button.
>
> > id="submit_tickets" onclick="this.disabled=true;
> document.ticket_form.submit();">
>
> Any suggestions would be greatly appreciated.
>
> Thanks,
> Skip
>
> --
> ====================================
> Skip Evans
> PenguinSites.com, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://penguinsites.com
> ------------------------------------
> Those of you who believe in
> telekinesis, raise my hand.
> -- Kurt Vonnegut
>
>
>
>

wow, i really think you're going about this all the wrong way. in your
code, you should check to see if the exact same details have just been
passed from the same IP within a certain time-limit, say half a second.
Now this isn't foolproof, but it's a lot better than using javascript
(which isn't always available remember) solution.

interestingly, this server-side solution also gets around the problem
where information is sent via get. some browsers send it twice in
attempt to download and display the page more quickly (as get behaves
very differently from post data)

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-lyNmojjTryW47jUDm4Hq--

Re: Disabling button onclick in IE

am 01.12.2009 22:43:54 von Andrew Ballard

On Tue, Dec 1, 2009 at 4:06 PM, Skip Evans wrote:
> Hey all,
>
> You probably remember me asking about disabling a submit button when it i=
s
> clicked to prevent double clicks submitting  a form for CC processin=
g.
>
> I put the following code into the submit button and it works fine on
> FireFox, but... hold your breath... not on IE.
>
> The button gets disabled but the form just sits there, not submitting. At
> first I just had
>
> onclick=3D"this.disabled=3Dtrue;"
>
> and that worked in FF also, but not in IE. Then I added the
>
> document.ticket_form.submit();
>
> But even that doesn't work with IE.
>
> Below is the whole snippet for the button.
>
> > id=3D"submit_tickets" onclick=3D"this.disabled=3Dtrue;
> document.ticket_form.submit();">
>
> Any suggestions would be greatly appreciated.
>

It looks like IE has an issue with your button being named "submit",
and is replacing the submit() method of the form with the element
named "submit". Try changing the name of the button.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Disabling button onclick in IE

am 01.12.2009 22:44:32 von TedD

At 9:16 PM +0000 12/1/09, Ashley Sheridan wrote:
>On Tue, 2009-12-01 at 15:06 -0600, Skip Evans wrote:
>wow, i really think you're going about this all the wrong way.

Ash:

I thought the same thing considering that I went through the exact
same problem and provided a solution, which he never mentioned.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Disabling button onclick in IE

am 01.12.2009 23:25:08 von Ryan Sun

--0015177404c608528b0479b23b5e
Content-Type: text/plain; charset=ISO-8859-1

Andrew is right, another solution is to move your code from onclick to
onsubmit event,



On Tue, Dec 1, 2009 at 4:06 PM, Skip Evans wrote:

> Hey all,
>
> You probably remember me asking about disabling a submit button when it is
> clicked to prevent double clicks submitting a form for CC processing.
>
> I put the following code into the submit button and it works fine on
> FireFox, but... hold your breath... not on IE.
>
> The button gets disabled but the form just sits there, not submitting. At
> first I just had
>
> onclick="this.disabled=true;"
>
> and that worked in FF also, but not in IE. Then I added the
>
> document.ticket_form.submit();
>
> But even that doesn't work with IE.
>
> Below is the whole snippet for the button.
>
> > id="submit_tickets" onclick="this.disabled=true;
> document.ticket_form.submit();">
>
> Any suggestions would be greatly appreciated.
>
> Thanks,
> Skip
>
> --
> ====================================
> Skip Evans
> PenguinSites.com, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://penguinsites.com
> ------------------------------------
> Those of you who believe in
> telekinesis, raise my hand.
> -- Kurt Vonnegut
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--0015177404c608528b0479b23b5e--

Re: Disabling button onclick in IE

am 02.12.2009 17:05:47 von Skip Evans

Yup. That was it. I found that Googling around as well.

Eesh.

Skip

Andrew Ballard wrote:
> On Tue, Dec 1, 2009 at 4:06 PM, Skip Evans wrote:
>> Hey all,
>>
>> You probably remember me asking about disabling a submit button when it is
>> clicked to prevent double clicks submitting a form for CC processing.
>>
>> I put the following code into the submit button and it works fine on
>> FireFox, but... hold your breath... not on IE.
>>
>> The button gets disabled but the form just sits there, not submitting. At
>> first I just had
>>
>> onclick="this.disabled=true;"
>>
>> and that worked in FF also, but not in IE. Then I added the
>>
>> document.ticket_form.submit();
>>
>> But even that doesn't work with IE.
>>
>> Below is the whole snippet for the button.
>>
>> >> id="submit_tickets" onclick="this.disabled=true;
>> document.ticket_form.submit();">
>>
>> Any suggestions would be greatly appreciated.
>>
>
> It looks like IE has an issue with your button being named "submit",
> and is replacing the submit() method of the form with the element
> named "submit". Try changing the name of the button.
>
> Andrew
>
>

--
====================================
Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Disabling button onclick in IE

am 02.12.2009 17:09:13 von Skip Evans

Hey all,

Tedd & Ash, yes, I'm definitely looking into solving it server
side, but I need this quick fix while I come with a solution
more along the lines of what you've both suggested.

Ash, how do you store the time stamp when the first request
comes through? Do you use a session variable or something like
that and when each request comes through compare the data with
any previous request within the half second or so?

Skip

tedd wrote:
> At 9:16 PM +0000 12/1/09, Ashley Sheridan wrote:
>> On Tue, 2009-12-01 at 15:06 -0600, Skip Evans wrote:
>> wow, i really think you're going about this all the wrong way.
>
> Ash:
>
> I thought the same thing considering that I went through the exact same
> problem and provided a solution, which he never mentioned.
>
> Cheers,
>
> tedd
>

--
====================================
Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Disabling button onclick in IE

am 02.12.2009 17:11:17 von Ashley Sheridan

--=-cJ1TaF4wezW2bFenKhrR
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2009-12-02 at 10:09 -0600, Skip Evans wrote:

> Hey all,
>
> Tedd & Ash, yes, I'm definitely looking into solving it server
> side, but I need this quick fix while I come with a solution
> more along the lines of what you've both suggested.
>
> Ash, how do you store the time stamp when the first request
> comes through? Do you use a session variable or something like
> that and when each request comes through compare the data with
> any previous request within the half second or so?
>
> Skip
>
> tedd wrote:
> > At 9:16 PM +0000 12/1/09, Ashley Sheridan wrote:
> >> On Tue, 2009-12-01 at 15:06 -0600, Skip Evans wrote:
> >> wow, i really think you're going about this all the wrong way.
> >
> > Ash:
> >
> > I thought the same thing considering that I went through the exact same
> > problem and provided a solution, which he never mentioned.
> >
> > Cheers,
> >
> > tedd
> >
>
> --
> ====================================
> Skip Evans
> PenguinSites.com, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://penguinsites.com
> ------------------------------------
> Those of you who believe in
> telekinesis, raise my hand.
> -- Kurt Vonnegut
>


I'll tell you about the problem I had.

One site was offering up contact details for sale on a contract basis.
The names were presented in a list of links, and clicking through
purchased those details for a 24-hour period.

When a visitor clicked on a link, it added an entry into a database
along with the current time. Because links are all GET data, the process
was performed twice by some browsers. Each time a details page was
displayed it checked to see if these details were requested by the same
user (using the login details) within a certain time period. If no
record was found, then a new purchase entry was made.

You could use this sort of thing on your own system as a general idea.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-cJ1TaF4wezW2bFenKhrR--

Re: Disabling button onclick in IE

am 02.12.2009 17:18:39 von Skip Evans

Okay, I'll work on something along those lines. In the
meantime, the JS will work better than nothing.

Thanks,
Skip

Ashley Sheridan wrote:
>
> I'll tell you about the problem I had.
>
> One site was offering up contact details for sale on a contract basis.
> The names were presented in a list of links, and clicking through
> purchased those details for a 24-hour period.
>
> When a visitor clicked on a link, it added an entry into a database
> along with the current time. Because links are all GET data, the process
> was performed twice by some browsers. Each time a details page was
> displayed it checked to see if these details were requested by the same
> user (using the login details) within a certain time period. If no
> record was found, then a new purchase entry was made.
>
> You could use this sort of thing on your own system as a general idea.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

--
====================================
Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Disabling button onclick in IE

am 02.12.2009 20:02:36 von TedD

At 10:09 AM -0600 12/2/09, Skip Evans wrote:
>Hey all,
>
>Tedd & Ash, yes, I'm definitely looking into solving it server side,
>but I need this quick fix while I come with a solution more along
>the lines of what you've both suggested.

A quick fix?

You've spent more time writing your question than it would take to do
a quick fix.

Quick fix:

1. Use javascript to deactivate the Submit button after it's clicked.

Here's an example of a javascript fix:

http://www.webbytedd.com/forms/single-submit1

2. Just in case the user has javascript disabled, then have your php
form generate a token and place that value in a session. That way,
upon a refresh (double click) you can check if the session contains
anything and if it does, then don't do anything.

Here's an example of a php fix:

http://www.webbytedd.com/forms/single-submit2

Keep in mind that your browser's session will be in effect upon
testing this. You should be able to get the idea.

Permanent fix:

Contact the Credit Card processing company and have them turn
"Duplicate Suppression" to ON.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php