Solved

Disabling a text box doesnt grey it out

Posted on 2003-12-04
4
1,578 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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 demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

831 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