?
Solved

Disabling a text box doesnt grey it out

Posted on 2003-12-04
4
Medium Priority
?
1,585 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 18

Accepted Solution

by:
SquareHead earned 80 total points
ID: 9880519
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
ID: 9880600
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
ID: 9881415

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

Assisted Solution

by:gam3r_3xtr3m3
gam3r_3xtr3m3 earned 80 total points
ID: 9881416
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
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…
Suggested Courses

752 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