Solved

Disabling a text box doesnt grey it out

Posted on 2003-12-04
4
1,580 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 20 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 20 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

749 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