Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Stop Function in JAVA SCRIPT

  1. #11
    Its kinda ok if the timer keeps going thats not a real issue but I am also trying to make that reset buttong work,
    -=Legacy Boy=-

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

  2. #12
    Banned
    Join Date
    Mar 2002
    Posts
    968
    Here ya go, the timer stops and everything...


    function startClock(){

    x = x+y

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



  3. #13
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255
    I took a look at your functions, and I think (now that I redid them in JS), this is what you were looking for. If not, let me know.

    Code:
    <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 = "";
    } 
    
    function bt0() {
      ticketnum = prompt("Please enter the ticket number to be tracked.");
      frm.txttick1.value = ticketnum;
      frm.txttime1.value = Date.UTC(Date.getTime());  
      startClock();
    }
    
    function bt1() {
      stopClock();
      frm.txttick1.value = "";
      frm.txttime1.value = "";
    }
    //--></SCRIPT> 
    <FORM NAME="frm"> 
    <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="btn0" onclick="bt0();" VALUE="START">
        </td>      
        <TD><center>
          <INPUT TYPE="TEXT" NAME="txttick1" READONLY SIZE=6 VALUE=""></center> 
        </td> 
        <TD><center> 
          <INPUT TYPE="TEXT" NAME="txttime1" READONLY SIZE=17 VALUE=""></center> 
        </td> 
        <td>
            <INPUT TYPE="TEXT" NAME="txtcount2" READONLY SIZE=2 VALUE=""> 
            <INPUT TYPE="TEXT" NAME="txtcount1" READONLY SIZE=2 VALUE="">
        </td> 
      </tr> 
      <tr> 
        <td>
          <INPUT TYPE="BUTTON" SIZE=10 NAME="btn1" onclick="bt1();" VALUE="CLEAR">
        </td>
      </tr>
    </table> 
    </FORM>
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  4. #14
    Banned
    Join Date
    Mar 2002
    Posts
    968
    Hey chsh, the reset works, but the clock and so don't seem to...

  5. #15
    Thanks for the help guys, It's working the way I need it to.
    Now for the really fun part I am going to try to make it track multiple tickets tommorow I let you know how it goes,

    thanks again,
    -=Legacy Boy=-

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

  6. #16
    Junior Member
    Join Date
    Jun 2002
    Posts
    7

    Wink Re: Stop Function in JAVA SCRIPT HELP!

    Hello! You might want to try using a loop to incriment opposed to having
    z = z+1 you can easily incriment by using z = z++ which will incriment z until
    a function calls z to be within certain boundaries. I removed the y *******
    because you do not really need the y ******* in this edited portion of your
    code. If that doesnt work, let me know, but it should only have your timer
    be activated once and makes sure it is only activated once. I believe the
    problem you were having could have simply been solved in your closing
    function by chaning an ******* to be out of the boundaries to be effected
    by your code. IF this doesnt work, like I said, let me know. Have not coded
    java in about 3 months so I am wee bit rusty. Been working on PHP shtuff.



    <SCRIPT LANGUAGE="Javascript"><!--

    var z = 0;
    var x = 0;

    function startClock()
    {

    document.frm.txtcount1.value = x;
    document.frm.txtcount2.value = z;
    setTimeout("startClock()", 1000);

    for(x=0;x<60;x++) // method of incrimentation
    {
    if ((x == 60)
    && (z <= 29)) // if both conditions are met. (used with z = 33)
    {
    x = 0; // return x to 0
    z = z++; // incriment z until it reaches 30
    }
    }
    if ((z >= 30)
    && (z <= 32))
    {
    alert(txttick1);
    document.frm.focus;
    z = 33; // return a value to z where it cannot be in the loop.
    }
    if (z >=33)
    {
    document.frm.txtcount1.value = "";
    document.frm.txtcount2.value = "";
    }
    return True;
    }

    //--></SCRIPT>
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Lumina
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Posting Permissions

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