Keeping Elements from Being Changed


Sometimes it may be necessary to automatically set the contents of a form element and keep the visitor from changing it. For example, you could have the visitor confirm information, or you could show a past history of transactions and then submit that information again with the new data collected. You can do this by making the element "read-only".

To keep elements from being changed:

Type readonly="readonly" in the form element's tag.

Figure 17.61. Add the readonly attribute to any form element that you want to show to your visitors but that you don't want them to change.


Figure 17.62. In this example, the visitor's prior votes are displayed in the read-only area. They can be viewedbut not changedby the visitor and then submitted with the new vote.


Tips

  • In HTML, you can just use readonly by itself. XHTML requires the redundant value.

  • You can use the readonly attribute in text boxes, password boxes, checkboxes, radio buttons, and text areas.

  • Setting the readonly attribute is something like using a hidden field without making it hidden. For more information on hidden fields, consult Creating Hidden Fields on page 271.





HTML, XHTML, & CSS(c) Visual QuickStart Guide
HTML, XHTML, and CSS, Sixth Edition
ISBN: 0321430840
EAN: 2147483647
Year: 2004
Pages: 340

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net