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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Javascript text button bug

    Hi

    when i click on the submit button "send"
    the text "send" will change to "one moment..."

    nice, but not completely. The problem occurs when someone hits
    the browser button HISTORY.BACK
    In mozilla firefox i tekst still displays "one moment"
    and worse of all... it aint clickable afterwards...

    here is what i have so far:
    // source of button.html
    Code:
    <html>
    <head>
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="expires" CONTENT="Tue, 31 Dec 2003 23:00:00 GMT">
    </head>
    <body>
    
    <form method="post" action="button2.html" name="button1">
    <input type="submit" name="enter" value="send" onclick="document.button1.enter.value='One moment ...';document.button1.enter.disabled=true;document.button1.submit();">
    </form>
    </body>
    </html>
    please help me out... i tried everything but it still won't work.

    Cheerz
    Jolan

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try resetting the values when the page loads, something like

    <script type="text/javascript">

    onload=function(){

    document.forms["button1"]["enter"].value="Send"
    document.forms["button1"]["enter"].disabled=false

    }

    </script>
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    FYI, it seems to work fine in FireFox 2.0 but not in FireFox 1.5

    There is likely a better way to do it but this way seems to work and should at least get you pointed towards a better fix. In the header put:

    Code:
    <script>
    window.onfocus = function () {
      document.button1.enter.value = "Send";
      document.button1.enter.disabled = false;
    }
    </script>
    david_kw

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb HTTP Response Header

    To force a new connection on back/forward I add these entries to the HTTP response header.

    Code:
    pragma: no-cache
    Cache-control: no-cache, no-store, must-revalidate
    Expires: 16 Jan 1980 01:12:00 GMT
    You can specify any past GMT date. I used my girlfriend's birthday here...

    If you don't know how to change the server's HTTP response settings, you can change the HTTP header with CGI.

    With ASP you can use:
    Code:
    <%
    response.setHeader("pragma", "no-cache"); response.setHeader("Cache-control", "no-cache, no-store, must-revalidate"); response.setHeader("Expires", "16 Jan 1980 01:12:00 GMT");
    %>
    <!-- Your HTML goes here. -->
    With PERL you can use this:
    Code:
    print <<"endHTML";
    pragma: no-cache
    Cache-control: no-cache, no-store, must-revalidate
    Expires: 16 Jan 1980 01:12:00 GMT
    Content-type:text/html
    
    <!-- make sure you leave the two new line chars above -->
    <!-- Your HTML goes here. -->
    endHTML
    With PHP you can use:
    PHP Code:
    <?php
    header
    ('pragma''no-cache');
    header('Cache-control''no-cache, no-store, must-revalidate');
    header('Expires''16 Jan 1980 01:12:00 GMT');
    ?>
    <!-- Your HTML goes here. -->
    Last edited by VortexCortex; 11-07-2006 at 07:06 PM. Reason: Added CGI examples.

  • #5
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by david_kw View Post
    FYI, it seems to work fine in FireFox 2.0 but not in FireFox 1.5

    There is likely a better way to do it but this way seems to work and should at least get you pointed towards a better fix. In the header put:

    Code:
    <script>
    window.onfocus = function () {
      document.button1.enter.value = "Send";
      document.button1.enter.disabled = false;
    }
    </script>
    david_kw
    funny, cos i have Firefox 1,5 running on my labtop
    and it works on that...

    on desktop i got FF 2.0 and it isn't running
    Ps. i haven't tested the onfocus yet...

  • #6
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    ok tested it...

    i am using PHP and the header
    Code:
    <?php
    header('pragma', 'no-cache');
    header('Cache-control', 'no-cache, no-store, must-revalidate');
    header('Expires', '16 Jan 1980 01:12:00 GMT');
    ?>
    the script however:
    Code:
    <script>
    window.onfocus = function () {
      document.button1.enter.value = "Send";
      document.button1.enter.disabled = false;
    }
    </script>
    DID work !
    but... one problem still remains...
    the test script i put in my first post
    is for one button only. But in many cases
    there can be multiple buttons...
    than its a problem cos i have to write multiple ONFOCUS

    like:
    document.button1.enter.value = "Send";...
    document.button2.enter.value = "Send";...
    document.button3.enter.value = "Send";...

    I guess the most simple solution would be to get
    rid off the multiple buttons.

    Anywayz, thanks A LOT!
    most forums didn't have no clue
    how to fix this...
    So Codingforums.com is gonna be in my Fav. list ;-)

    Cheerz to you all!


  •  

    Posting Permissions

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