Solved

Disabling a text box doesnt grey it out

Posted on 2003-12-04
4
1,572 Views
Last Modified: 2008-03-10
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
Comment
Question by:mrigank
4 Comments
 
LVL 18

Accepted Solution

by:
SquareHead earned 20 total points
Comment Utility
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
 
LVL 5

Author Comment

by:mrigank
Comment Utility
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
 

Expert Comment

by:Priya25
Comment Utility

You should set the css of your button  to blank
button.CssClass = ""
0
 
LVL 7

Assisted Solution

by:gam3r_3xtr3m3
gam3r_3xtr3m3 earned 20 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now