E-Squared
asked on
Disable submit button after click (Interdev DesignerControl Button)... why isn't this easy?
I have been blessed to be given a huge legacy of web code written in Visual InterDev 6.0. We are having a problem with duplicate orders being submitted when users click submit multiple times. I assumed this would be an easy fix... just disable the button on the first click, right?
Well, I couldn't figure it out. So we assigned it to the previously-senior-but-now- parttime-p rogrammer who wrote most of the stuff in the first place and SHE couldn't figure it out.
I searched the web fruitlessly. The question is too specific, or too vague, or something, to be susceptible to easy search terms. (Suggestions welcome!)
My company understandably doesn't want me to spend days on such a simple problem, coming up to speed on all the ins and outs of interdev controls and writing/rewriting ASPs just to fix what should be a simple problem. I would really appreciate anyone's help.
The pages are VB .ASP and the submit button is some special Microsoft control and looks like this in the source page (not visible from inside interdev, but what is written out to the actual .asp file):
<!--METADATA TYPE="DesignerControl" startspan
<OBJECT
classid="clsid:B6FC3A14-F8 37-11D0-9C C8-0060080 58731"
height=27 id=btnSubmit
style="HEIGHT: 27px; LEFT: 0px; TOP: 0px; WIDTH: 206px"
width=206>
<PARAM NAME="_ExtentX" VALUE="5450">
<PARAM NAME="_ExtentY" VALUE="714">
<PARAM NAME="id" VALUE="btnSubmit">
<PARAM NAME="Caption" VALUE="">
<PARAM NAME="Image" VALUE="images/ButtonSubmit .gif">
<PARAM NAME="AltText" VALUE="Submit this new order.">
<PARAM NAME="Visible" VALUE="-1">
<PARAM NAME="Platform" VALUE="0">
<PARAM NAME="LocalPath" VALUE="">
</OBJECT>
-->
<!--#INCLUDE FILE="_ScriptLibrary/Butto n.ASP"-->
<SCRIPT LANGUAGE=JavaScript RUNAT=Server>
function _initbtnSubmit()
{
btnSubmit.src = 'images/ButtonSubmit.gif';
btnSubmit.alt = 'Submit this new order.';
btnSubmit.setStyle(1);
}
function _btnSubmit_ctor()
{
CreateButton('btnSubmit', _initbtnSubmit, null);
}
</script>
<% btnSubmit.display %>
<!--METADATA TYPE="DesignerControl" endspan-->
The event handler looks like this:
[<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub btnSubmit_onclick()
{Code to submit order here}
End Sub
</SCRIPT>
When visiting the page, the client source shows the control rendered thus:
<A href="javascript:thisPage. _fireEvent ('btnSubmi t','onclic k');"><IMA GE border=0 name="btnSubmit" id="btnSubmit" src="images/ButtonSubmit.g if" alt="Submit this order.">
The easiest way to fix this, I thought, would be to disable the submit button. But, I don't have access to the inner javascript of the control when it is displayed or I'd just disable it from the client side:
"javascript:{control.visib le=false or something!};thisPage._fire Event('btn Submit','o nclick');"
So then I tried putting server-side code at the top of the btnSubmit_onclick event to disable or make the button invisible.
document.getElementById("l blresubmit ").style.v isibility = "visible"
Didn't work. I realized it probably had to be a client action. So I tried
Response.Write "<SCRIPT language=vbscript>document .getElemen tById('lbl resubmit') .style.vis ibility = 'invisible'</SCRIPT>"
(Well... I don't know if the syntax above is correct, but I did do it right when I was trying it.)
Which 'works' but the problem is that when you click the submit button, it refreshes the page (but doesn't navigate to a new one, yet, until the server response is received), and the response.write output ends up being first in the source, before <HTML>, when there IS no control yet.
I can think of several methods to prevent actual submission of the second and subsequent orders, but the best thing would be to disable the button (while it waits for a response from the server which loads a new page).
Ready to tear my hair out,
-E²
P.S. Thank you very much for your time!!!
Well, I couldn't figure it out. So we assigned it to the previously-senior-but-now-
I searched the web fruitlessly. The question is too specific, or too vague, or something, to be susceptible to easy search terms. (Suggestions welcome!)
My company understandably doesn't want me to spend days on such a simple problem, coming up to speed on all the ins and outs of interdev controls and writing/rewriting ASPs just to fix what should be a simple problem. I would really appreciate anyone's help.
The pages are VB .ASP and the submit button is some special Microsoft control and looks like this in the source page (not visible from inside interdev, but what is written out to the actual .asp file):
<!--METADATA TYPE="DesignerControl" startspan
<OBJECT
classid="clsid:B6FC3A14-F8
height=27 id=btnSubmit
style="HEIGHT: 27px; LEFT: 0px; TOP: 0px; WIDTH: 206px"
width=206>
<PARAM NAME="_ExtentX" VALUE="5450">
<PARAM NAME="_ExtentY" VALUE="714">
<PARAM NAME="id" VALUE="btnSubmit">
<PARAM NAME="Caption" VALUE="">
<PARAM NAME="Image" VALUE="images/ButtonSubmit
<PARAM NAME="AltText" VALUE="Submit this new order.">
<PARAM NAME="Visible" VALUE="-1">
<PARAM NAME="Platform" VALUE="0">
<PARAM NAME="LocalPath" VALUE="">
</OBJECT>
-->
<!--#INCLUDE FILE="_ScriptLibrary/Butto
<SCRIPT LANGUAGE=JavaScript RUNAT=Server>
function _initbtnSubmit()
{
btnSubmit.src = 'images/ButtonSubmit.gif';
btnSubmit.alt = 'Submit this new order.';
btnSubmit.setStyle(1);
}
function _btnSubmit_ctor()
{
CreateButton('btnSubmit', _initbtnSubmit, null);
}
</script>
<% btnSubmit.display %>
<!--METADATA TYPE="DesignerControl" endspan-->
The event handler looks like this:
[<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub btnSubmit_onclick()
{Code to submit order here}
End Sub
</SCRIPT>
When visiting the page, the client source shows the control rendered thus:
<A href="javascript:thisPage.
The easiest way to fix this, I thought, would be to disable the submit button. But, I don't have access to the inner javascript of the control when it is displayed or I'd just disable it from the client side:
"javascript:{control.visib
So then I tried putting server-side code at the top of the btnSubmit_onclick event to disable or make the button invisible.
document.getElementById("l
Didn't work. I realized it probably had to be a client action. So I tried
Response.Write "<SCRIPT language=vbscript>document
(Well... I don't know if the syntax above is correct, but I did do it right when I was trying it.)
Which 'works' but the problem is that when you click the submit button, it refreshes the page (but doesn't navigate to a new one, yet, until the server response is received), and the response.write output ends up being first in the source, before <HTML>, when there IS no control yet.
I can think of several methods to prevent actual submission of the second and subsequent orders, but the best thing would be to disable the button (while it waits for a response from the server which loads a new page).
Ready to tear my hair out,
-E²
P.S. Thank you very much for your time!!!
ASKER
No luck so far... it looks like I'm going to have to, chunk by chunk, move elements from the page in question to a new page to see what the do and how they affect what's happening. Maybe in the process I'll figure it out. :(
It looks like this btnSubmit button has a PARAM NAME=VISIBLE that you can probably set to 0 on refresh.
Alternatively, in your page's onload event, you can call a function that will set the style.visible property as you were trying before...
<SCRIPT language=javascript>
function window_onload() {
document.getElementById('b tnSubmit') .style.vis ibility = 'hidden';
}
</SCRIPT>
<body onload="window_onload();">
Alternatively, in your page's onload event, you can call a function that will set the style.visible property as you were trying before...
<SCRIPT language=javascript>
function window_onload() {
document.getElementById('b
}
</SCRIPT>
<body onload="window_onload();">
ASKER
Thanks ftaco96, I will try it out.
One of the weird things is that the page doesn't seem to refresh until I try to write new script out to the client side. I haven't given up, but I am temporarily working on other things in the hope that enlightenment will come from the depths of the ether.
One of the weird things is that the page doesn't seem to refresh until I try to write new script out to the client side. I haven't given up, but I am temporarily working on other things in the hope that enlightenment will come from the depths of the ether.
ASKER
Thank you for your efforts, Venabili.
The problem was just solved a couple days ago. I don't know what all the details are (and I plan to ask for them) but from what I can see the main code is:
<script language="vbscript">
Sub btnSubmit_onclick
document.thisForm.btnSubmi t.disabled = true
End Sub
</script>
I don't know if there is any other supporting code, but it works like a charm.
The problem was just solved a couple days ago. I don't know what all the details are (and I plan to ask for them) but from what I can see the main code is:
<script language="vbscript">
Sub btnSubmit_onclick
document.thisForm.btnSubmi
End Sub
</script>
I don't know if there is any other supporting code, but it works like a charm.
ASKER
Oh, so... no one gets points because on one's ideas worked (and I tried all ideas presented).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if IsPostBack Then
btnSubmit.enabled = False
end if