Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1590
  • Last Modified:

Disabling a text box doesnt grey it out

I am using a text box and enable it or disable it depending on user selection of a drop down.
When the text box is disabled, the page does not allow it to enter values but the text box does not get greyed out. I am using document.form.value.textbox.disabled = true.
Is there a way in which i can grey out the text box when it is disabled.
0
mrigank
Asked:
mrigank
2 Solutions
 
SquareHeadCommented:
You'll notice that the text box does not gray out, but if there was any text in the text box, THAT would be grayed out... The easiest way to gray out the text box itself would be to assign a style to it... Like this:

<input type="text" value="" Disabled style="background:#DFDFDF;">
0
 
mrigankAuthor Commented:
Your solution works .. but i have a problem .... i want to set the color in my javascript cos the javascript disables or enables the text box ... so how can i do that in my javascript ..

document.form.value.style.background = "#DFDFDF;";

is it correct ????
0
 
Priya25Commented:

You should set the css of your button  to blank
button.CssClass = ""
0
 
gam3r_3xtr3m3Commented:
try this:

<script language="JavaScript" type="text/javascript">
function checkSelect(this1){
if(this1.selectedIndex==1){
document.form1.textbox1.disabled = true
document.form1.textbox1.style.background = "#DFDFDF";}
else{
document.form1.textbox1.disabled = false
document.form1.textbox1.style.background = "#FFFFFF";}}
</script>
<body>
<form name="form1" onSubmit="return false;">
<select name="selectbox1" onChange="checkSelect(this);" onLoad="checkSelect(this);">
<option>Enabled</option>
<option>Disabled</option>
</select><br />
<input type="text" name="textbox1" />
</form>
</body>
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now