SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist Mr. Tech's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form disable problems...

    Hi!

    I need to be able to disable the sugbmit form field. This is my code:

    <script language="JavaScript1.2">
    function postaction(f){
    if (f.elements[0].type == 'submit') {
    f.elements[0].disabled = true;
    }
    postaction = blockIt;
    return false;
    }

    function blockIt(f) {
    return false;
    }
    </script>


    <form name="form" action="surf.php?userid=<? echo $id; ?>&username=<? echo $username; ?>" method="get"><input type="submit" value="NEXT SITE" onClick="postaction(form);"></form>

    But when I click Next Site, it disables it for one second, and the disables it so you can click it again...

    Is there a way to completely disable it?

    Thanks!

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onClick="return postaction(this);"

    function postaction(oSubmit) {
    oSubmit.disabled = true;
    postaction = blockIt;
    return false;
    }
    ::: certified wild guess :::

  3. #3
    SitePoint Evangelist Mr. Tech's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    I'll give it a go!

  4. #4
    SitePoint Evangelist Mr. Tech's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, still didn't work... It disables it only for 1 second then goes back... The page is sort of javascript inside JavaScript or something... This is all my code:

    <html>
    <head>
    </head>
    <body>

    <!-- This is where it counts down and displays the next button -->
    <div id="countDownText"></div>
    <font onClick="postaction();">
    <div id="next"></div>
    </font>


    <a href="#"><font color="#000066" style="text-decoration:underline" onClick="pause();"><strong>PAUSE SITE</strong></font></a>
    </body>
    </HTML>

    <script language="JavaScript1.2">
    var duration=22;
    var minimum=23;
    var mode='Click';
    var countDownText;
    //document.getElementById("next" ).visibility='hidden';

    function postaction(oSubmit) {
    oSubmit.disabled = true;
    postaction = blockIt;
    return false;
    }
    function blockIt(f) {
    return false;
    }

    var countDownTime=duration
    function initializebar(){
    startIE=setInterval("increase()",1000)
    }


    function increase(){
    if (minimum >= 0){
    document.getElementById("countDownText" ).innerHTML='<center><strong><font color=Green>'+minimum+'</font><font color=#000066> seconds left to next Site</font></strong></center>'
    } else {
    document.getElementById("countDownText" ).innerHTML='<center><strong><font color=#000066>Click Next Site</font></strong></center>'
    document.getElementById("next" ).innerHTML='<form name="form" action="surf.php?userid=<? echo $id; ?>&username=<? echo $username; ?>" method="get"><input type="submit" name="next" value="NEXT SITE" onClick="return postaction(next);"></form>';
    //<a href="#"><font color="#000066" style="text-decoration:underline" onClick="postaction();"><strong></strong></font></a>
    }
    if (countDownTime<=duration){
    window.status="User: <? print $username; ?> | <? print $_SESSION['user_points']; ?>"
    countDownTime--
    minimum--
    } else {
    window.status="Paused"
    document.getElementById("countDownText" ).innerHTML='<center><strong><font color=#000066>Paused</font></strong></center>'
    document.getElementById("next" ).innerHTML='<strong><a href="#"><font onClick=postaction() color=#000066>RESUME</font></a></strong>';
    }
    if (countDownTime==0) {
    window.status=''
    //clearInterval(startIE)
    //postaction()
    }
    }
    window.onload=initializebar
    function pause() {
    countDownTime=3600;
    }
    </script>


Bookmarks

Posting Permissions

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