Link to home
Start Free TrialLog in
Avatar of PhillipsWellness
PhillipsWellness

asked on

Disabled submit button doesn't reset on back button on firefox and safari

Hi,

I'm having trouble with a submit button that is being disabled on a search form not showing up as re-enabled if the user clicks back.  This only happens in Firefox & Safari.  On IE, when the user hits BACK, they see the button in it's original state (not in its disabled state).

Here is code you can test:

Filename:  test.htm
Code:

<script>
function doLoad() {
myForm.submit_button.value = 'Searching...'
myForm.submit_button.disabled = true;
}
</script>
<form action="test2.htm" name="myForm" onSubmit="doLoad();" method="post">
<input type="submit" name="submit_button" value="Search" />
</form>

Filename:  test2.htm
code:
This is my test results page.<br />
<br />
<a href="javascript:history.go(-1);">Click Here</a> to go back.

It seems it could be an issue with how firefox & safari handle the cache and history.  My desired result is that when the user clicks BACK (or we do a history.go(-1)) on the resulting page, that when the browser goes back, they see an ENABLED button that says 'Search' and not the DISABLED button that still says 'Searching...'.  This is how it functions on IE.

Thanks in adavnce for your help!

Sincerely,

Dave Phillips
Avatar of cwolves
cwolves

add:

document.onload = function(){
    myForm.submit_button.disabled = false;
}
Avatar of PhillipsWellness

ASKER

cwolves - Thank you, but unfortunately, that doesn't solve my problem.  You would think it would, but if you test it in Firefox and/or Safari, you still have the same result.  Works great in IE, but that's not where my problem is.
I'm bumping this up to 500.  I would really like the answer to this!!!
sorry, it's window.onload, not document.onload:

window.onload = function(){
    myForm.submit_button.disabled = false;
}
and to do it properly:

window.onload = function(){
    document.forms.myForm.submit_button.disabled = false;
}
Still doesn't change anything.  I've also tried the same thing in the onLoad attribute of the <body> tag and doesn't change the situation.  Still doesn't work in firefox or safari.

If someone could test this in a firefox or safari browser and get it working, I'd be greatly obliged!

Thanks!
It works fine for me in firefox.  I'm running v1.5
Using this:

<input type="submit" id="submit" value="submit">

I can tell you that this definitely works in FireFox, infact any Mozilla browser:

<body onload="document.getElementById('submit').disabled = true;">

This also definitely works:

<body onload="document.myForm.submit.disabled = true;">

But first, I would try this:

<input type="submit" id="submit" value="submit" disabled="disabled">

If that doesn't work, then you got real problems.  In that case, start a new document and try from there.
You are right in that it displays properly in Firefox on page load.  However, this is AFTER the submit when the form action page loads, if you then hit BACK on the browser, the original submit button is still disabled.  It should have reset back to disabled = false.

Unfortunately, I still don't have a solution.
ASKER CERTIFIED SOLUTION
Avatar of cwolves
cwolves

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial