Solved

Grey out textfield

Posted on 2000-04-24
5
936 Views
Last Modified: 2012-08-13
How do you grey out a textfield? Make it read-only
0
Comment
Question by:funksoul
[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
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allow link tag to be submit like form 15 60
Expanding/Collapsing Tree on SharePoint List 29 62
Form submit takes only for one form 23 53
Error just appeared 3 23
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

734 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