Solved

Grey out textfield

Posted on 2000-04-24
5
896 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
Comment Utility
<Input Type="Text" Name="Firstname" Value="Smith" Readonly>

Dave
0
 
LVL 8

Expert Comment

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

772 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

12 Experts available now in Live!

Get 1:1 Help Now