Current location: Hot Scripts Forums » General Web Coding » JavaScript » How to execute "Disable" immediately?


How to execute "Disable" immediately?

Reply
  #1 (permalink)  
Old 05-25-06, 10:48 AM
StuartMack StuartMack is offline
Newbie Coder
 
Join Date: May 2006
Location: High Wycombe, England
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
How to execute "Disable" immediately?

Hi

I am developing a web application using Java Script.
I DON'T want to allow to a user clicking on any buttons
during some operation (DB update, for example).

I have the following code:
1. Disable all buttons
2. Perform data operation
3. Enable the buttons back

The problem is that the Disable operation (1) doesn't execute immediately.
It seems like the disable operation (1) executes asynchronously together
with the data operation (2).

How can I make disable to execute immediately?

P.S. I tried to use setTimeout before the data operation (2), but it didn't help.

Thanks
Reply With Quote
  #2 (permalink)  
Old 05-25-06, 03:33 PM
jfulton's Avatar
jfulton jfulton is offline
Community VIP
 
Join Date: Apr 2006
Location: Los Angeles, CA
Posts: 660
Thanks: 0
Thanked 0 Times in 0 Posts
Could you post the code you have?
Reply With Quote
  #3 (permalink)  
Old 05-26-06, 02:14 AM
StuartMack StuartMack is offline
Newbie Coder
 
Join Date: May 2006
Location: High Wycombe, England
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
function onClickButtonFilterSearch()
{
  document.all("btnSearch").disabled = true;
  iCallID = ManagerService.callService(onLoadGetFilterResult, filter.CallObject);
}

The callService() is asynchronous (AJAX), but since I call it after the disable operation I expect the disable to perform first.

function onLoadGetFilterResult(result)
{
  if((result.error)&&(iCallID==result.id))  
 {    
  raiseError(result);
 }
 else
 {
  var dom = result.value;
 }

  // code to fill the ListBox here
  document.all("btnSearch").disabled = false;

}

Last edited by TwoD; 05-26-06 at 05:57 AM. Reason: Please use [code][/code] wrappers.
Reply With Quote
  #4 (permalink)  
Old 05-26-06, 06:00 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not sure why it wouldn't disable the button before sending the call...

However, I wouldn't use the document.all collection for anything. It only exists in IE and ruins the code for every other browser.
Use document.getElementById('btnSearch') instead.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute perl neo130 Perl 7 10-18-05 03:47 PM
n00b: perl to execute a php file -[OnTarget]- Perl 1 04-10-05 12:59 PM
execute code - then mail()... HOW?? nassau PHP 4 03-04-05 08:59 AM
IP Address/computer name(i need immediately) bsujin Website Reviews 0 05-10-04 12:00 AM
Freelance PHP/Mysql programmer available immediately jpstewar Job Offers & Assistance 0 10-03-03 06:24 PM


All times are GMT -5. The time now is 11:10 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.