Anyone, HELP! - Graying Disabled fields after Back.

B

Bubba Gump

I hope someone can help here.
I'm creating a form that disables certain fields depending on the users
choices. But I've noticed that Disabled fields aren't "grayed out" (ie: you
can't tell they're disabled until you try to select them. Very annoying).

So I added code to manually change the background color of these fields
when a particular option is selected. Problem is, if they use their Back
button to return (like after a bad Submit), the normal white color returns
(even though they're still disabled).

The "Back" button doesn't trip an "onLoad" event, so I can't add code to
correct the colors manually.

Is there a way to "fix" the Disabled property so that disabled fields are
automatically grayed out even after clicking "Back"?

PS: Disabling "Back" and forcing the user to reload the page is not an
option because it wipes all all their prior entires and forces them to
start over. I don't want to do that.

Thanks in advance.
 
E

Evertjan.

Bubba Gump wrote on 27 jan 2006 in comp.lang.javascript:
I'm creating a form that disables certain fields depending on the
users
choices. But I've noticed that Disabled fields aren't "grayed out"
(ie: you can't tell they're disabled until you try to select them.
Very annoying).

What do you mean by "fields" in the HTML sense?

I only know them in the Database record sense.
[and in the grazy sense]

Do you mean buttons?

Or <input type='text'>?

=============

If you mean the latter:


<form onsubmit='doGray();'>
<input name='field1' id='f' type='text'>
</form>

<script type="text/javascript">
function doGray(){
var f = document.getElementById('f');
f.enabled = false;
f.style.backgroundColor='gray';
}
</script>
 
B

Bubba Gump

Bubba Gump wrote on 27 jan 2006 in comp.lang.javascript:
I'm creating a form that disables certain fields depending on the
users
choices. But I've noticed that Disabled fields aren't "grayed out"
(ie: you can't tell they're disabled until you try to select them.
Very annoying).

What do you mean by "fields" in the HTML sense?

I only know them in the Database record sense.
[and in the grazy sense]

Do you mean buttons?

Or <input type='text'>?

Hi Evertjan, thanks for the fast reply, but you've only given me what I
already have.
I'm manually changing the background color of input objects (typically
text boxes) that I disable, but if you leave the page and return using your
browsers Back button or javascript:go.history(-1);, the colors reset back
to normal.

I already know how to change the color. Now I want them to stay that way.
If you mean the latter:

<form onsubmit='doGray();'>

-*- Bubba -*-
 
E

Evertjan.

Bubba Gump wrote on 27 jan 2006 in comp.lang.javascript:
Hi Evertjan, thanks for the fast reply, but you've only given me what
I already have.
I'm manually changing the background color of input objects
(typically
text boxes) that I disable, but if you leave the page and return using
your browsers Back button or javascript:go.history(-1);, the colors
reset back to normal.

I already know how to change the color. Now I want them to stay that
way.

That is impossible, since the page is restarted. This is a recurring Q here
that people would like the back-function to work differently from what it
actually does.

There are two options:
1 persist in trying to have is work like you want.
2 try a different approach of your concept.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top