...

View Full Version : Javascript text button bug



joland
11-07-2006, 04:42 PM
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


<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

Mr J
11-07-2006, 05:35 PM
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>

david_kw
11-07-2006, 05:49 PM
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:



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


david_kw

VortexCortex
11-07-2006, 05:51 PM
To force a new connection on back/forward I add these entries to the HTTP response header.



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:


<%
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:


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
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. -->

joland
11-07-2006, 07:35 PM
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:



<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...

joland
11-07-2006, 07:46 PM
ok tested it...

i am using PHP and the header


<?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:


<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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum