Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Mission Code: Take your time

    Breifing:
    At 2130 hours today I decided I want to produce a script that so many people are in the hunt for.

    Now a certain person as commented to me that it impossible to do.

    Mission:
    To create a function that alerts you a Confirm message, that gives a choice to continue or not. if cancel obviously end function, but if ok,
    continue to another alert. You cannot click ok on this next alert until the set time runs out. And Then Finally the final task of this is NO elements are to be used in this script.

    Final Words:
    Hooah!!!
    Last edited by GSimpson; 08-07-2006 at 11:40 AM.
    The internet is my Sandbox, and notepad is my Spade n' Bucket.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Provo, UT
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do you mean "NO elements are to be used"?
    I try to convince 'em that I am computer geek, but I just can't do it. Why? Oh why?

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Provo, UT
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how is this?

    Code:
    var someamountoftime = 10000;
    var timerDone = false;
    
    document.onload = new function (){
    	firstConfirm = confirm("do you want to continue?");
    	if(firstConfirm){
    		mytimer = setTimeout("timersDone()",someamountoftime);
    		secondConfirm();
    	}
    }
    
    function timersDone(){
    	timerDone = true;
    }
    
    function secondConfirm(){
    	secondContinue = confirm("do you want to conitue again?");
    	if(secondContinue && timerDone){
    		alert("sweet");
    	}else{
    		secondConfirm();
    	}
    }
    Yeah you are right it does let them click the ok button but it pops it back up again until they have waited the amount of time that I set.

    And I think there are no elements.

    The html is.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Mission</title>
    <script language="javascript" type="text/javascript" src="mission.js"></script>
    </head>
    
    <body>
    </body>
    </html>
    I try to convince 'em that I am computer geek, but I just can't do it. Why? Oh why?

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Provo, UT
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is impossible to kep people from clicking the ok button (I think) so I guess you could make your own popup using dhtml. which is possible but would be quite a bit of work.
    I try to convince 'em that I am computer geek, but I just can't do it. Why? Oh why?

  • #5
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Ok we're getting somewhere

    I'm not quite sure I explained that right,
    So you click on a button for example
    then you get a confirm box asking if you would like to continue -
    If cancel then finsh function but if ok then display an alert for 10 seconds.
    When the 10 seconds is up you can finish function and your variable goes up by one.

    however we are making progress.
    I was thinking timeouts? - but I dont know too much so...
    Last edited by GSimpson; 08-08-2006 at 01:36 AM.
    The internet is my Sandbox, and notepad is my Spade n' Bucket.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Provo, UT
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var someamountoftime = 10000;
    var timerDone = false;
    var countSomething = 0;
    
    function startIt(){
    	firstConfirm = confirm("do you want to continue?");
    	if(firstConfirm){
    		mytimer = setTimeout("timersDone()",someamountoftime);
    		secondConfirm();
    		countSomething++;
    	}
    }
    
    function timersDone(){
    	timerDone = true;
    }
    
    function secondConfirm(){
    	alert("You will be able to continue in 10 seconds");
    	if(timerDone){
    		return;
    	}else{
    		secondConfirm();
    	}
    }
    But I would think that instead on an alert box I would make a div tag and pop that up instead. I hope this helps.
    I try to convince 'em that I am computer geek, but I just can't do it. Why? Oh why?

  • #7
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    It looks to me that your code will freeze the browser for ever on the last alert...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #8
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks alot Mike. I think I shall nominate you.
    The internet is my Sandbox, and notepad is my Spade n' Bucket.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •