Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disable html elements using CSS

 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible to disable html elements ( text field, drop down) using CSS ? i know its possible using Java Script , just wondering if its possible using CSS; it is a requirement related to JSF , so if CSS can do the job it will make my job easy

Thanks,
Rajeev
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it does not need JavaScript and you can not do it with CSS

The elements have an attribute disabled which you need to set.

Eric
 
Linda Walters
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "when" and "how" of disabling them is what is important here.

For example, if the user selects a certain item from a combobox that may, depending on the value, enable or disable certain other HTML tags on the page. This should be done with a JavaScript function that changes state of the disabled attribute of form tags or even the visibility of other HTML tags.

If you are sending an entire page from the server via JSP/JSF or just by composing HTML in Java or with XSLT, then you should set this in the server. However it is initially set, if there is a possibility that the user can do something that will change it, then you should have the JavaScript option too.

Just my $0.02 worth.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic