spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / java_dhtml / chap8 / 2 To page 1To page 2current pageTo page 4To page 5To page 6To page 7To page 8
[previous] [next]

JavaScript & DHTML Cookbook, Chapter 8: Dynamic Forms

Java Developer (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume
Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans


Disabling Form Controls

NN 6 IE 4

Problem

You want to temporarily lock down a form control to prevent user access to the control.

Solution

In IE 4 or later and NN 6 or later, form controls provide a Boolean disabled property that scripts can change at any time. Use any valid reference to the form control to set its disabled property to true:

document.myForm.myFirstTextBox.disabled = true;

To restore functionality to the control, set its disabled property to false:

document.myForm.myFirstTextBox.disabled = false;

A disabled form control generally displays a greyed-out appearance and does not permit user modification of the setting.

Discussion

Figure 8-2 shows the form from Figure 8-1 with form controls disabled. While scripts can still read and write values in disabled controls, a disabled form control's name/value pair does not submit to the server at submission time.

Figure 8-2. A form with disabled controls

 

IE 4 and later for Windows provides a more pervasive disabled property, available to all renderable element objects. But the property is not fully inheritable. For example, if you set the disabled property of a form element object to true, the nested controls might look disabled (as will their text labels), but users can still access the controls to modify their content. If you want to disable both the labels and controls in IE for Windows, disable the controls and the containing form at the same time. IE 5 for Macintosh and Netscape 6 or 7 do not support disabling of nonform elements.

See Also

Recipe 8.10 for hiding portions of a form until they're needed; Recipe 12.7 for hiding and showing elements.


home / programming / java_dhtml / chap8 / 2 To page 1To page 2current pageTo page 4To page 5To page 6To page 7To page 8
[previous] [next]


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger

Created: March 27, 2003
Revised: May 6, 2003

URL: http://webreference.com/programming/java_dhtml/chap8/2