Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox Check Delay 1

Status
Not open for further replies.

Signit

MIS
Oct 17, 2003
114
US
I have a page where I am opening a window to perform a ping and then returning those results to the page the user is presently on. This action is performed through a combination of JavaScript and ColdFusion. While, the actual method of pinging and returning the results to the screen works just fine there is a potential problem with users who might become "happy clickers." If a user clicks a checkbox and then clicks another checkbox too quickly the second checkbox will override the window opening for the first checkbox. I have provided a Check All option which alleviates some of the potential for this problem but I would like to create a more programmatic workaround.

I have attempted to write a pause function which works but creates a bad user experience as the page seems to just sit there before moving forward. Ideally I'd like to dynamically create a different window if one is already open.

Ping Function
Code:
    function ping(checkbox_key,ipAddress)
    {
      if(typeof pingWindow != "undefined")
      {
	  if (typeof pingWindow.name != "undefined") 
        pause(2000);
      }
      
      pingWindow = window.open("","pingWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=1,height=1,top=0,left=0");
      pingWindow.blur();
      pingWindow.creator = self;
      pingWindow.location.href = "#templatepath#/scanme_ping.cfm?checkbox_key=" + checkbox_key + "&ipaddress=" + ipAddress;
      return;
    }

Pause Function
Code:
function pause(millis) 
{
  date = new Date();
  var curDate = null;
  
  do {
    var curDate = new Date();
  }
  while(curDate-date < millis);
}
 
As long as you're taking the time to open and close a browser window each time a checkbox is checked, perhaps created a unique window for each checkbox will prevent the jam:

Code:
[b]var pingWindow = new Array();[/b]
function ping(checkbox_key,ipAddress)
    {
      [b]var winName = "pingWindow"+checkbox_key;[/b]
      pingWindow[b][checkbox_key][/b] = window.open("",[b]winName[/b],"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=1,height=1,top=0,left=0");
      pingWindow[b][checkbox_key][/b].blur();
      pingWindow[b][checkbox_key][/b].creator = self;
      pingWindow[b][checkbox_key][/b].location.href = "#templatepath#/scanme_ping.cfm?checkbox_key=" + checkbox_key + "&ipaddress=" + ipAddress;
      return;
    }

'hope this helps.

--Dave
 
That worked perfectly. Thank you for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top