Stop Function in JAVA SCRIPT
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Stop Function in JAVA SCRIPT

  1. #1
    Member
    Join Date
    Oct 2001
    Posts
    64

    Exclamation Stop Function in JAVA SCRIPT HELP!

    Well here is what I have I basically got it working the way it should except for I can't make the function stop. after the timer hits 30 minutes it send the alert, but it keeps sending the alert I want it to halt all processes there, but I can't find the code? Any ideas?

    Thanks

    -=LB=-















    <HTML>
    <SCRIPT LANGUAGE="Javascript"><!--
    var z = 0
    var x = 0
    var y = 1

    function startClock(){

    x = x+y

    document.frm.txtcount1.value = x
    document.frm.txtcount2.value = z
    setTimeout("startClock()", 1000)
    if(x==60){
    z=z+1
    x=0 }
    if(z==30){
    alert(txttick1);
    document.frm.focus

    }

    }



    function stopClock() {
    x=0
    z=0
    document.frm.txtcount1.value = ""
    document.frm.txtcount2.value = ""
    }


    //--></SCRIPT>

    <TABLE>
    <TR>
    <TD></td>
    <TD>Ticket Number</td>
    <TD><center>Submit Time</center></td>
    <TD>Minutes Seconds</td>
    </tr>
    <TR>
    <TD>
    <INPUT TYPE="BUTTON" SIZE=10 NAME="button0" VALUE="START"> </td>
    <TD><center>
    <INPUT TYPE="TEXT" NAME="txttick1" READONLY SIZE=6 VALUE=""&GT;></center> </td>
    <TD><center>
    <INPUT TYPE="TEXT" NAME="txttime1" READONLY SIZE=17 VALUE=""&GT;></center> </td>

    <td>
    <FORM NAME="frm">
    <INPUT TYPE="TEXT" NAME="txtcount2" READONLY SIZE=2 VALUE=""&GT;>
    <INPUT TYPE="TEXT" NAME="txtcount1" READONLY SIZE=2 VALUE=""&GT;>
    </FORM>
    </td>
    </tr>
    <tr>
    <td>
    <INPUT TYPE="BUTTON" SIZE=10 NAME="button1" VALUE="CLEAR"></td>
    </table>

    <SCRIPT LANGUAGE="VBScript" >




    Sub button0_onclick


    ticketnum = InputBox("Please enter the ticket number to be tracked.")

    txttick1.value=ticketnum
    txttime1.value=now

    startClock()


    End Sub


    Sub button1_onclick
    txttick1.value=""
    txttime1.value=""


    End sub





    </SCRIPT >


    </HTML>

  2. #2
    Senior Member
    Join Date
    Jul 2001
    Posts
    420
    These are guess but I'd look into break and exit or maybe document.close().
    If you spend more on coffee than on IT security, you will be hacked. What\'s more, you deserve to be hacked.
    -- former White House cybersecurity adviser Richard Clarke

  3. #3
    Member
    Join Date
    Oct 2001
    Posts
    64
    Thanks I try those commands,
    Programing is so much fun,

    -=Legacy Boy=-

    -= You mean there is stuff better then DOS? =-

  4. #4
    Member
    Join Date
    Oct 2001
    Posts
    64
    Well not matter where I try to put the break statement or the other ones it ether does not start at all or has no effect,

    Can any one see where the problem is here or somthing else to try. I just am trying to get the little clock from ticking and blank the 2 feilds,

    heres the newer code,


    =====================
    <HTML>
    <TITLE>Ticket Timer V 0.1</TITLE>
    <SCRIPT LANGUAGE="Javascript"><!--
    var z = 0
    var x = 0
    var y = 1

    function startClock(){

    x = x+y

    document.frm.txtcount1.value = x
    document.frm.txtcount2.value = z
    setTimeout("startClock()", 1000)
    if(x==60){
    z=z+1
    x=0
    }

    if(z==1){
    alert(txttick1);
    document.frm.focus


    }

    }




    //--></SCRIPT>

    <TABLE>
    <TR>
    <TD></td>
    <TD>Ticket Number</td>
    <TD><center>Submit Time</center></td>
    <TD>Minutes Seconds</td>
    </tr>
    <TR>
    <TD>
    <INPUT TYPE="BUTTON" SIZE=10 NAME="button0" VALUE="START" onClick= startClock() > </td>
    <TD><center>
    <INPUT TYPE="TEXT" NAME="txttick1" READONLY SIZE=6 VALUE=""&GT;></center> </td>
    <TD><center>
    <INPUT TYPE="TEXT" NAME="txttime1" READONLY SIZE=17 VALUE=""&GT;></center> </td>

    <td>
    <FORM NAME="frm">
    <INPUT TYPE="TEXT" NAME="txtcount2" READONLY SIZE=2 VALUE=""&GT;>
    <INPUT TYPE="TEXT" NAME="txtcount1" READONLY SIZE=2 VALUE=""&GT;>
    </FORM>
    </td>
    </tr>
    <tr>
    <td>
    <INPUT TYPE="BUTTON" SIZE=10 NAME="button1" VALUE="CLEAR"></td>
    </table>

    <SCRIPT LANGUAGE="VBScript" >




    Sub button0_onclick


    ticketnum = InputBox("Please enter the ticket number to be tracked.")

    txttick1.value=ticketnum
    txttime1.value=now




    End Sub


    Sub button1_onclick
    txttick1.value=""
    txttime1.value=""


    End sub





    </SCRIPT >


    </HTML>
    -=Legacy Boy=-

    -= You mean there is stuff better then DOS? =-

  5. #5
    Banned
    Join Date
    Mar 2002
    Posts
    968
    Here's a suggestion.
    It's not an alert but a pop-up instead.

    Put this on your "main" page, it the body tag...

    <BODY onLoad="setTimeout(window.close, xxxx)">
    xxxx being the time set (ie: 60000 = 60secs or minute)

    Then write the pop-up page with this coding within... (ie: popup.html)
    <html>
    <head>
    <title>...</title>
    <SCRIPT LANGUAGE="JavaScript">
    function popupPage() {
    var page = "popup.html"; <--- Change this to your popup page
    windowprops = "height=500,width=500,location=no," <-- change these variables to your liking
    + "scrollbars=no,menubars=no,toolbars=no,resizable=no";

    window.open(page, "Popup", windowprops); <-- name your file here
    }
    </script>
    </head>
    <BODY onLoad="setTimeout('popupPage()', xxxx);"> <--- set your time...
    content of message/alert...
    </body>
    </html>

  6. #6
    Senior Member
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    735
    I haven't actually read the whole code yet (I'm lazy), but it seems that in one function, you have it calling itself every 1000 miliseconds. 1000 miliseconds is a 1 second, so the function will just keep looping every second.

  7. #7
    Member
    Join Date
    Oct 2001
    Posts
    64
    Originally posted here by jethro
    I haven't actually read the whole code yet (I'm lazy), but it seems that in one function, you have it calling itself every 1000 miliseconds. 1000 miliseconds is a 1 second, so the function will just keep looping every second.
    The reason that I have the 1 second thing in the function I need to time somthing for 30 minutes to remind ppl to make a fallow up call on th issue.


    Thanks Tyger_claw I will give that a try, But will that stop the loop?
    -=Legacy Boy=-

    -= You mean there is stuff better then DOS? =-

  8. #8
    Banned
    Join Date
    Mar 2002
    Posts
    968
    It won't give you the alert option that you are looking for, it's more of a replacement to it.

    I'm trying to see the problem with your code, but figured I'd give you this as a sub for the time being...

  9. #9
    Member
    Join Date
    Oct 2001
    Posts
    64
    Thanks Dude,

    just run it I have it set to go off at 1 minute,
    -=Legacy Boy=-

    -= You mean there is stuff better then DOS? =-

  10. #10
    Banned
    Join Date
    Mar 2002
    Posts
    968
    I've got it half way...

    instead of...
    if(x==60)
    z=z+1
    x=0


    put y=0


    the pop-ups stop, but the minute counter starts to go....

    Also, your stopClock() function is ignored...
    Took it out and nothing went wrong...

Posting Permissions

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