473,811 Members | 2,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d isable=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 3089
I have made some progress and found a few interesting things:
1) I should use just onload="if (btn_id.disable d)", not
onload="if(docu ment.formname.b tnname.disabled );" on grandparent form; That
works in FireFox, but not IE6 [which I target],
where I had to use: if(document.get ElementById('bt n_Id').disabled )

2) for some reason that always returns false, even if I just set
<input name="name1" id="btn_id" onclick="disabl ed=true"(or
this.disabled=t rue )
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.disable d) { alert.window('s ome 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******@veriz on.netwrote in message
news:mpHSg.1280 7$2G1.1696@trnd dc07...
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.d isable=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******@veriz on.netwrote in message
news:mpHSg.1280 7$2G1.1696@trnd dc07...
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.d isable=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*****@verizo nDOT.netwrote in message
news:V41Tg.3863 $Dq3.2039@trndn y06...
"Oleg Konovalov" <ok******@veriz on.netwrote in message
news:mpHSg.1280 7$2G1.1696@trnd dc07...
>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.d isable=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.d isable=true;" />
and
<body onload="if (document.myBtn .disabled) document.myBtn. disabled=false; "
/>
...
</body>
Maybe like this ?

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

Try this:

onclick="this.d isabled=true;th is.value='Submi tting...';
this.form.submi t();"

As in:

<form action="somePro gram.cgi">
<input type="submit" id="btnSubmit" value="Submit"
onclick="this.d isabled=true;th is.value='Submi tting...';
this.form.submi t();">
</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.disable d)",
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.disable d) { alert.window('s ome text'); }" gives error:
certainly same cause as (2)
"Oleg Konovalov" <ok******@veriz on.netwrote in message
news:mpHSg.1280 7$2G1.1696@trnd dc07...
>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.d isable=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.oneA ttribute

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

document.forms['myForm'].elements['myElement'].disabled=true;
or
document.myForm .myElement.disa bled='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.ph p" onsubmit="retur n 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
2119
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 adding users, and one form for removing users. I want to be able to add a user, click the submit button, add another user, click the submit button again, and so on, BUT, disallow adding a user and then hitting refresh (which would add the same...
2
4792
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 a login page, from which I use a DB check to verify user/password info. Also, I have a bit loggedIN field in the DB, which I use to see if they are currently logged in; if so, I prevent them from logging in a second time. Problem: Unless they...
7
1800
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 like copy, select-all, or file-save-as? Thanks!
15
2485
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 the list frame (with a special color). Now this mark function is meant to toggle the mark status in the list frame, i.e. switch it on with the first click and off with the second. Problem is, the marking works, but the second click will not have...
1
2841
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 open in new tab/window button works for them. Is there some setting I am missing that allows this to feature to work correctly? I don't have any code purposely preventing pages from being opened in the same window...don't know why that happens.
13
636
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 again, which created duplicate records. So I am trying to disable the button as soon as it is clicked, and as soon as it's done, re-enable it again.
15
4516
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 I might have a solution. It is somewhat complicated, but it probably ought to work.... Forget disabling right click menus and the like, it seems to me that the problem is screen capture.
2
1387
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 jQuery’s style of calls: $('#id1').click().fadeOut('slow'). A problem I have ran into though is how to prevent a form from submitting if it fails one of the validation methods. I know how returning false to the form on submission will do the...
1
2296
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 code (ie. right clicking for form design mode, F11 for the container, etc.) I'm testing this with two buttons on a form in a very simple app containing one table with 3 columns, 2 rows of data and one form based
2
2817
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 button again (or at least detect that an authorisation is already in progress and do nothing) while the first authorisation is in progress. Can someone help me out? I've tried the following but none of the solutions work: 1) Disabling the...
0
10647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10398
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.