473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Preventing second click

Hi,

I have a web application which is (among other things) doing large SQL
Insert's,
so sometimes it takes a while, user becomes impatient and clicks again (or
just does double-click),
so the same data is getting inserted again.

I was thinking of some simple solution in Javascript.

something like:
<input name=myBtn onclick="this.disable=true;" />
and
<body onload="if (document.myBtn.disabled) document.myBtn.disabled=false;"
/>
....
</body>

Do you think that might work ?
(that input is not a Submit button, the page actually reloads when any DB
transaction is done)

The complication is that the <bodyand <inputare in different files,
i.e. if the button is in the "grandchild" of the <bodyform (child includes
the parent which includes a grandparent).
Do they really share a "document" ?

Or is there a nicer solution ?

Please advise.
Thank you in advance,
Oleg.

Sep 28 '06 #1
6 3044
I have made some progress and found a few interesting things:
1) I should use just onload="if (btn_id.disabled)", not
onload="if(document.formname.btnname.disabled);" on grandparent form; That
works in FireFox, but not IE6 [which I target],
where I had to use: if(document.getElementById('btn_Id').disabled)

2) for some reason that always returns false, even if I just set
<input name="name1" id="btn_id" onclick="disabled=true"(or
this.disabled=true )
I have never heard that reloading a page resets any of its attributes and
there are no other buttons with the same id or name.

3) the other strange thing is that I can't use any curly braces in any
onload or onclick, doing:
onload="if (btn_id.disabled) { alert.window('some text'); }" gives error:
Fatal: File SystemId Unknown; Line 16; Column -1; Could not find function:
window.alert
but runs just fine without curly braces
That looks like a problem to me. Any workarounds ?

TIA,
Oleg.
"Oleg Konovalov" <ok******@verizon.netwrote in message
news:mpHSg.12807$2G1.1696@trnddc07...
Hi,

I have a web application which is (among other things) doing large SQL
Insert's,
so sometimes it takes a while, user becomes impatient and clicks again (or
just does double-click),
so the same data is getting inserted again.

I was thinking of some simple solution in Javascript.

something like:
<input name=myBtn onclick="this.disable=true;" />
and
<body onload="if (document.myBtn.disabled) document.myBtn.disabled=false;"
/>
...
</body>

Do you think that might work ?
(that input is not a Submit button, the page actually reloads when any DB
transaction is done)

The complication is that the <bodyand <inputare in different files,
i.e. if the button is in the "grandchild" of the <bodyform (child
includes the parent which includes a grandparent).
Do they really share a "document" ?

Or is there a nicer solution ?

Please advise.
Thank you in advance,
Oleg.



Sep 28 '06 #2
"Oleg Konovalov" <ok******@verizon.netwrote in message
news:mpHSg.12807$2G1.1696@trnddc07...
Hi,

I have a web application which is (among other things) doing large SQL
Insert's,
so sometimes it takes a while, user becomes impatient and clicks again (or
just does double-click),
so the same data is getting inserted again.

I was thinking of some simple solution in Javascript.

something like:
<input name=myBtn onclick="this.disable=true;" />
and
<body onload="if (document.myBtn.disabled) document.myBtn.disabled=false;"
/>
...
</body>

Do you think that might work ?
(that input is not a Submit button, the page actually reloads when any DB
transaction is done)

The complication is that the <bodyand <inputare in different files,
i.e. if the button is in the "grandchild" of the <bodyform (child
includes the parent which includes a grandparent).
Do they really share a "document" ?

Or is there a nicer solution ?

Please advise.
Many technical solutions, but before getting too technical, don't forget to
cue the user that he/she must wait.
When I do this via xmlHTTPRequest, I change the image on the link from
'Save' to 'Wait'. I also have the submit handler set a flag whether form
has already been submitted, which the xmlHTTPRequest event handler clears on
server response.

---Bruce Wisentaner
Sep 29 '06 #3
Bruce,

Most users know they have to wait, but sometimes they perform massive
updates
(e.g. insert 200 rows), and when a server is slow, they tend to become
impatient
and click that button again. Or just simply do double-click instead of a
single click.

So it would be more effective to just disable that button until the DB
transaction is finished
when screen is refreshed with the new data.

Actually, it's a complex Cocoon/XSLT web app with actions in Java,
but I thought that there should be a simple Javascript solution with
disabling & re-enabling that button.

So what would you suggest ?

TIA,
Oleg.

"Bruce Wisentaner" <br*****@verizonDOT.netwrote in message
news:V41Tg.3863$Dq3.2039@trndny06...
"Oleg Konovalov" <ok******@verizon.netwrote in message
news:mpHSg.12807$2G1.1696@trnddc07...
>Hi,

I have a web application which is (among other things) doing large SQL
Insert's,
so sometimes it takes a while, user becomes impatient and clicks again
(or just does double-click),
so the same data is getting inserted again.

I was thinking of some simple solution in Javascript.

something like:
<input name=myBtn onclick="this.disable=true;" />
and
<body onload="if (document.myBtn.disabled)
document.myBtn.disabled=false;" />
...
</body>

Do you think that might work ?
(that input is not a Submit button, the page actually reloads when any DB
transaction is done)

The complication is that the <bodyand <inputare in different files,
i.e. if the button is in the "grandchild" of the <bodyform (child
includes the parent which includes a grandparent).
Do they really share a "document" ?

Or is there a nicer solution ?

Please advise.

Many technical solutions, but before getting too technical, don't forget
to cue the user that he/she must wait.
When I do this via xmlHTTPRequest, I change the image on the link from
'Save' to 'Wait'. I also have the submit handler set a flag whether form
has already been submitted, which the xmlHTTPRequest event handler clears
on server response.

---Bruce Wisentaner


Sep 29 '06 #4
Oleg Konovalov wrote:

<input name=myBtn onclick="this.disable=true;" />
and
<body onload="if (document.myBtn.disabled) document.myBtn.disabled=false;"
/>
...
</body>
Maybe like this ?

<INPUT type="button" value="send"
onclick="alert('onlyOnce');this.onclick='';this.va lue='wait'">
Sep 29 '06 #5
Oleg Konovalov wrote:
>
<input name=myBtn onclick="this.disable=true;" />
and
<body onload="if (document.myBtn.disabled) document.myBtn.disabled=false;"
/>
...
</body>

Try this:

onclick="this.disabled=true;this.value='Submitting ...';
this.form.submit();"

As in:

<form action="someProgram.cgi">
<input type="submit" id="btnSubmit" value="Submit"
onclick="this.disabled=true;this.value='Submitting ...';
this.form.submit();">
</form>

Sep 29 '06 #6
ASM
Oleg Konovalov a écrit :
I have made some progress and found a few interesting things:
1) I should use just onload="if (btn_id.disabled)",
I can't believe that works with other browser than IE (Win ?)
2) for some reason that always returns false,
see below
3) the other strange thing is that I can't use any curly braces in any
onload or onclick, doing:
onload="if (btn_id.disabled) { alert.window('some text'); }" gives error:
certainly same cause as (2)
"Oleg Konovalov" <ok******@verizon.netwrote in message
news:mpHSg.12807$2G1.1696@trnddc07...
>Hi,

I have a web application which is (among other things) doing large SQL
Insert's,
so sometimes it takes a while, user becomes impatient and clicks again (or
just does double-click),
so the same data is getting inserted again.

I was thinking of some simple solution in Javascript.

something like:
<input name=myBtn onclick="this.disable=true;" />
OK
>and
<body onload="if (document.myBtn.disabled) document.myBtn.disabled=false;"
/>
I do not understand why IE can't find an element of a form ?
(if what you said is true)

document.myForm.myElement.oneAttribute

where : myForm and myElement are names (not ID !) of those

document.forms['myForm'].elements['myElement'].disabled=true;
or
document.myForm.myElement.disabled='disabled';

<form name="myForm" .... >
<input type="submit" name="myElement" ... >

>...
</body>

Do you think that might work ?
yes (as told in my other post) if your code is correct :-)
>(that input is not a Submit button, the page actually reloads when any DB
transaction is done)
Why isn't it a submit ?

prefer to use a submit button and put your conditional function in a
'onsubmit' in form's tag

<form action="page.php" onsubmit="return myConditions();" ... >

myConditions() must return false to avoid send,
if all ok it must return true

>The complication is that the <bodyand <inputare in different files,
that's new ... !
one way to other, in fine, you display a single file, no ?
>i.e. if the button is in the "grandchild" of the <bodyform (child
includes the parent which includes a grandparent).
I understand nothing about your family where children give birth to
their parents and grand parents ... ! ?
Voodoo ?
>Do they really share a "document" ?
yes a virtual document but working as normal one
>Or is there a nicer solution ?
Hope so for your familly :-)

--
ASM
Oct 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Matt | last post by:
I have an interactive web page that I need to prevent refreshes on. The problem is that I want to ALLOW resubmissions, but only via the submit button. My web page has two forms on it, one form for...
2
by: BenM | last post by:
Description: I would like to prevent a user from logging in with their user/password combination on a different computer or even a different browser window, if they are already logged in. I have...
7
by: Rex | last post by:
Hi all, I want to protect the data on my web page ; I want to make it viewing-only. I've already disabled right-click, but can I take it one step further, and disable certain pulldown menus...
15
by: bvdb | last post by:
Hello, my web-application uses two frames, one with a list of database records, one with a record detail view. From the detail view there is "mark" function that will mark the respective record in...
1
by: R Reyes | last post by:
Hi, For some reason, the website I made does not open pages in a new page whenever I right-click "Open in New Tab" or "Open in New Window". But, as soon as I navigate to any other website, the...
13
by: Oleg Konovalov | last post by:
Hi, I have a Java GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks...
15
by: Baron Samedi | last post by:
Every so often, I see someone wanting to prevent heir images being downloaded and the general consensus is "you can't". Now a friend has asked me to think some more about this, and I think that...
2
by: dwmartin18 | last post by:
I got it into my head the other day to develop my own little form validation library. More than anything I just wanted to try out of few things I’ve never done before like chainable methods -- think...
1
by: RLN | last post by:
RE: Access 2003 Current setup is: Front end .mdb (Interface, queries, macros, etc) /Back end .mdb (Database Tables) I'm trying to write some code that will prevent users from getting into the...
2
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.