spazjr01
asked on
How do I disable an ImageButton until the web page is completely loaded?
I am working on a web app. And, I have an ImageButton object that throws an error, if it is clicked before the page load completes. It is set up, via javascript, as a Calendar button that is tied to an input field. There is some processing that occurs on the input field that is causing this problem (if the button is clicked prior to completion). So, I want to know how to disable this ImageButton until the entire page is completely loaded. I searched around and determined (maybe incorrectly so) that I should do this within the onLoad atrribute of the Body. Note: this is also where the function is called that is doing the processing that causes the error when the button is clicked prematurely). I thought that if I start with a disabled imagebutton first, I could reenable it as the final onLoad statement. But, that hasn't worked so far, as I am getting an error. Please correct this solution or suggest a different one that works. I am knowledgeable in C#, but very new to HTML/Javascript, so I need baby step-type solution please.
My current code:
<body onload=populateCurrDate('t bArrDate', 'tbDSDateTime', 'tbALocDateTime', 'tbPLocDateTime'); document.forms[0]btnArrDat e.disabled =false;">
where btnArrDate is the ImageButton that I want to enable. But, I get the following runtime error: 'document.forms.0.btnArrDa te' is null or not an object. But, it is establish later in the <form> ....</form> definition. And, I thought onload executes after the page is loaded. If not, what do I use?
My current code:
<body onload=populateCurrDate('t
where btnArrDate is the ImageButton that I want to enable. But, I get the following runtime error: 'document.forms.0.btnArrDa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Shouldn't
"document.forms[0]btnArrDa te"
...be
"document.forms[0].btnArrD ate"
...instead?
I realize this is not an answer, but I am curious what the button does and how it is causing an error.
"document.forms[0]btnArrDa
...be
"document.forms[0].btnArrD
...instead?
I realize this is not an answer, but I am curious what the button does and how it is causing an error.
ASKER
Slimfinger,
You are correct. That was simply a typo when I posted the question. My code actually had document.forms[0].btnArrDa te. Sorry for the confusion.
You are correct. That was simply a typo when I posted the question. My code actually had document.forms[0].btnArrDa
ASKER