Solved

Grey out textfield

Posted on 2000-04-24
5
910 Views
Last Modified: 2012-08-13
How do you grey out a textfield? Make it read-only
0
Comment
Question by:funksoul
5 Comments
 
LVL 19

Expert Comment

by:daveamour
ID: 2746307
<Input Type="Text" Name="Firstname" Value="Smith" Readonly>

Dave
0
 
LVL 8

Expert Comment

by:xabi
ID: 2746476
This will be a better solution:

<input type="text" name="foo" value ="foo" onfocus="this.blur()" Readonly>

cause readonly tag is only IE compatible.

xabi
0
 

Author Comment

by:funksoul
ID: 2747228
I need to know how to do this by using Javascript...

document.forms[0].elements[0].disabled=true

but this only works for IE...does Netscape support grey-out readonly.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 25 total points
ID: 2747266
Xabis solution is correct, however it always disables the field.

Here is ow it should be

<input type="text" name="foo" value ="foo" onfocus="if (this.disabled) this.blur()">

it will NOT be greyed out in Netscape but it WILL be disabled using
document.forms[0].elements[0].disabled=true;

Michel
0
 

Author Comment

by:funksoul
ID: 2747519
I wish I could give you both points...but thanks fo r the help...only wish Netscape has the grey out option too.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

896 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

15 Experts available now in Live!

Get 1:1 Help Now