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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    reset fails: onClick = doc.form.name.value=""

    New, but I've used this reset method successfully:

    onClick = document.form.name.value=""

    (from JSKit) but somehow it doesn't work in the code below -- values keep re-appearing in two text boxes. Is there something about the script itself as I've modified it that is the problem? The timer and counter work fine, the reset button does not. I've placed the script inside the <body> tags because I want to put the counter and reset buttons inside a page with other scripts once they're done. Thanks.

    <body bgcolor="#FFFFFF">

    <script language="JavaScript">
    <!--
    //on-screen timer
    //JavaScriptKits at http://www.javascriptkit.com/
    //modified by Bob Higgins
    var c=0;
    document.go.timer.value="";
    function count()
    {
    document.go.timer.value=c;
    c=c+1;
    if (c>5){
    document.go.timer.value=5;
    document.go.txtMsg.value=("TIME IS UP!!!");
    document.close();
    }
    setTimeout("count()",1000);
    }

    //-->
    </script>

    <form name="go">
    <input type="text" name="timer" size="12">
    <input type="button" value="Start" onClick="count()">
    <input type="text" name="txtMsg" value="" size="26">
    <input type="button"
    name="resetButton"
    value="Reset"
    onClick = document.go.timer.value='';document.go.txtMsg.value=''
    >
    </form>

    </body>

  • #2
    New Coder
    Join Date
    Jul 2002
    Location
    Portugal
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try instead of name attribute to use de ID attribute
    You don't want to know...

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Too many thing wrong to list them all...

    <html>
    <head>
    </head>
    <body bgcolor="#FFFFFF" onload="document.go.reset()">
    <script language="JavaScript">
    <!--
    //on-screen timer
    //JavaScriptKits at http://www.javascriptkit.com/
    //modified by Bob Higgins
    var c=0;
    function count()
    {
    document.go.timer.value=c;
    c=c+1;
    if (c>5){
    document.go.timer.value=5;
    document.go.txtMsg.value="TIME IS UP!!!";
    } else timerID = setTimeout("count()",1000);
    }
    //-->
    </script>
    <form name="go">
    <input type="text" name="timer" size="12">
    <input type="button" value="Start" onClick="count()">
    <input type="text" name="txtMsg" value="" size="26">
    <input type="button" name="resetButton" value="Reset"
    onClick = "c=0;clearTimeout(timerID);timer.value='';txtMsg.value=''">
    </form>
    </body>
    </html>

  • #4
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks caldasgsm and adios.

    Adios, I have much to learn! and will study your successful changes. Key seems to be leaving out the 'else' statement after the 'if' and especially clearing the setTimeout -- a lesson I had not gotten to yet. Thanks again.


  •  

    Posting Permissions

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