Working with Hidden Fields


The data in a hidden field gets submitted along with the rest of the form to the Web server, but the visitor doesn't usually know about it, since the hidden field is completely invisible on the page, as Figure 68.4 shows.

Figure 68.4. A hidden field contains form data, but the visitor can't see it, because the field is invisible.


FAQ

I don't like the Browse button. Can I change it?

Nope. You're stuck with it. HTML doesn't let you change its label or make it disappear.


Listing 68.4. View Source for Figure 68.4.
 <form>   <input type="hidden" name="referringPage" value="newsletter.htm"> </form> 

Designers occasionally use hidden fields for mischief, but normally these fields are completely innocent. In the example in Figure 68.4, the hidden field contains the name of the page that submitted the form, which is handy to know if your site contains multiple forms that look more or less the same.

FAQ

Can my visitors change the content of a hidden field?

Not directly. Because hidden fields are invisible, the visitor can't edit or change their values. However, JavaScript functions can update the value of a hidden field quite easily.


Even though the visitor doesn't see the data in the hidden field, the Web server receives it like this:

 referringPage=newsletter.htm 



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

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