By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 941 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Anyone, HELP! - Graying Disabled fields after Back.

P: n/a
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.

--
-*- Bubba -*-
Jan 27 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 27 '06 #2

P: n/a
"Evertjan." <ex**************@interxnl.net> wrote in
news:Xn********************@194.109.133.242:
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 -*-
Jan 27 '06 #3

P: n/a
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.